mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-05-13 20:21:25 -05:00
Compare commits
3 Commits
v0.3-april
...
v0.3-april
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
323c457809 | ||
|
|
decc1f563f | ||
|
|
e5892c0fae |
40
main.lua
40
main.lua
@@ -81,7 +81,7 @@ function love.draw()
|
|||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.printf(
|
love.graphics.printf(
|
||||||
string.format("%.2f", 1 / love.timer.getAverageDelta()) ..
|
string.format("%.2f", 1.0 / love.timer.getAverageDelta()) ..
|
||||||
"fps - " .. version, 0, 460, 635, "right"
|
"fps - " .. version, 0, 460, 635, "right"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -290,6 +290,7 @@ function love.resize(w, h)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local TARGET_FPS = 60
|
local TARGET_FPS = 60
|
||||||
|
local FRAME_DURATION = 1.0 / TARGET_FPS
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
|
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
|
||||||
@@ -299,7 +300,7 @@ function love.run()
|
|||||||
local dt = 0
|
local dt = 0
|
||||||
|
|
||||||
local last_time = love.timer.getTime()
|
local last_time = love.timer.getTime()
|
||||||
local time_accumulator = 0
|
local time_accumulator = 0.0
|
||||||
return function()
|
return function()
|
||||||
if love.event then
|
if love.event then
|
||||||
love.event.pump()
|
love.event.pump()
|
||||||
@@ -320,24 +321,39 @@ function love.run()
|
|||||||
if scene and scene.update and love.timer then
|
if scene and scene.update and love.timer then
|
||||||
scene:update()
|
scene:update()
|
||||||
|
|
||||||
local frame_duration = 1.0 / TARGET_FPS
|
if time_accumulator < FRAME_DURATION then
|
||||||
if time_accumulator < frame_duration then
|
|
||||||
if love.graphics and love.graphics.isActive() and love.draw then
|
if love.graphics and love.graphics.isActive() and love.draw then
|
||||||
love.graphics.origin()
|
love.graphics.origin()
|
||||||
love.graphics.clear(love.graphics.getBackgroundColor())
|
love.graphics.clear(love.graphics.getBackgroundColor())
|
||||||
love.draw()
|
love.draw()
|
||||||
love.graphics.present()
|
love.graphics.present()
|
||||||
end
|
end
|
||||||
local end_time = last_time + frame_duration
|
|
||||||
local time = love.timer.getTime()
|
-- request 1ms delays first but stop short of overshooting, then do "0ms" delays without overshooting (0ms requests generally do a delay of some nonzero amount of time, but maybe less than 1ms)
|
||||||
while time < end_time do
|
for milliseconds=0.001,0.000,-0.001 do
|
||||||
love.timer.sleep(0.001)
|
local max_delay = 0.0
|
||||||
time = love.timer.getTime()
|
while max_delay < FRAME_DURATION do
|
||||||
|
local delay_start_time = love.timer.getTime()
|
||||||
|
if delay_start_time - last_time < FRAME_DURATION - max_delay then
|
||||||
|
love.timer.sleep(milliseconds)
|
||||||
|
local last_delay = love.timer.getTime() - delay_start_time
|
||||||
|
if last_delay > max_delay then
|
||||||
|
max_delay = last_delay
|
||||||
|
end
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
while love.timer.getTime() - last_time < FRAME_DURATION do
|
||||||
|
-- busy loop, do nothing here until delay is finished; delays above stop short of finishing, so this part can finish it off precisely
|
||||||
end
|
end
|
||||||
time_accumulator = time_accumulator + time - last_time
|
|
||||||
end
|
end
|
||||||
time_accumulator = time_accumulator - frame_duration
|
|
||||||
|
local finish_delay_time = love.timer.getTime()
|
||||||
|
local real_frame_duration = finish_delay_time - last_time
|
||||||
|
time_accumulator = time_accumulator + real_frame_duration - FRAME_DURATION
|
||||||
|
last_time = finish_delay_time
|
||||||
end
|
end
|
||||||
last_time = love.timer.getTime()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
zip -r cambridge.love libs load res scene tetris conf.lua main.lua scene.lua funcs.lua
|
zip -r cambridge.love libs load res scene tetris conf.lua main.lua scene.lua funcs.lua
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
./package
|
#!/bin/sh
|
||||||
|
|
||||||
|
./package-love.sh
|
||||||
mkdir dist
|
mkdir dist
|
||||||
mkdir dist/windows
|
mkdir dist/windows
|
||||||
mkdir dist/win32
|
mkdir dist/win32
|
||||||
@@ -202,13 +202,13 @@ end
|
|||||||
local cool_cutoffs = {
|
local cool_cutoffs = {
|
||||||
frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36),
|
frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36),
|
||||||
frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30),
|
frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30),
|
||||||
frameTime(0,27), frameTime(0,27), frameTime(0,27),
|
frameTime(0,30), frameTime(0,30), frameTime(0,30),
|
||||||
}
|
}
|
||||||
|
|
||||||
local regret_cutoffs = {
|
local regret_cutoffs = {
|
||||||
frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50),
|
frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50),
|
||||||
frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40),
|
frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42),
|
||||||
frameTime(0,35), frameTime(0,35), frameTime(0,35),
|
frameTime(0,42), frameTime(0,42), frameTime(0,42),
|
||||||
}
|
}
|
||||||
|
|
||||||
function PhantomMania2Game:updateSectionTimes(old_level, new_level)
|
function PhantomMania2Game:updateSectionTimes(old_level, new_level)
|
||||||
|
|||||||
49
tetris/rulesets/arika_exp.lua
Normal file
49
tetris/rulesets/arika_exp.lua
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
local Piece = require 'tetris.components.piece'
|
||||||
|
local Ruleset = require 'tetris.rulesets.arika_ace2'
|
||||||
|
|
||||||
|
local ARS = Ruleset:extend()
|
||||||
|
|
||||||
|
ARS.name = "ARS-X"
|
||||||
|
ARS.hash = "ArikaEXP"
|
||||||
|
|
||||||
|
ARS.MANIPULATIONS_MAX = 24
|
||||||
|
ARS.ROTATIONS_MAX = 12
|
||||||
|
|
||||||
|
function ARS:onPieceCreate(piece, grid)
|
||||||
|
piece.manipulations = 0
|
||||||
|
piece.rotations = 0
|
||||||
|
piece.lowest_y = -math.huge
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:checkNewLow(piece)
|
||||||
|
for _, block in pairs(piece:getBlockOffsets()) do
|
||||||
|
local y = piece.position.y + block.y
|
||||||
|
if y > piece.lowest_y then
|
||||||
|
piece.manipulations = 0
|
||||||
|
piece.rotations = 0
|
||||||
|
piece.lowest_y = y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:onPieceMove(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- move reset
|
||||||
|
if piece:isDropBlocked(grid) then
|
||||||
|
piece.manipulations = piece.manipulations + 1
|
||||||
|
if piece.manipulations >= ARS.MANIPULATIONS_MAX then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:onPieceRotate(piece, grid, upward)
|
||||||
|
piece.lock_delay = 0 -- rotate reset
|
||||||
|
if upward or piece:isDropBlocked(grid) then
|
||||||
|
piece.rotations = piece.rotations + 1
|
||||||
|
if piece.rotations >= ARS.ROTATIONS_MAX and piece:isDropBlocked(grid) then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ARS
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
local Ruleset = require 'tetris.rulesets.standard_exp'
|
local Ruleset = require 'tetris.rulesets.standard_ace'
|
||||||
|
|
||||||
local SRS = Ruleset:extend()
|
local SRS = Ruleset:extend()
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ SRS.wallkicks_line = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|
||||||
|
|
||||||
|
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
local kicks
|
local kicks
|
||||||
if piece.shape == "O" then
|
if piece.shape == "O" then
|
||||||
return
|
return
|
||||||
@@ -69,6 +69,12 @@ function SRS:checkNewLow(piece)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SRS:onPieceCreate(piece, grid)
|
||||||
|
piece.manipulations = 0
|
||||||
|
piece.rotations = 0
|
||||||
|
piece.lowest_y = -math.huge
|
||||||
|
end
|
||||||
|
|
||||||
function SRS:onPieceDrop(piece, grid)
|
function SRS:onPieceDrop(piece, grid)
|
||||||
self:checkNewLow(piece)
|
self:checkNewLow(piece)
|
||||||
if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then
|
if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then
|
||||||
|
|||||||
2
tetris/rulesets/arika_srs.lua → tetris/rulesets/standard_ace.lua
Executable file → Normal file
2
tetris/rulesets/arika_srs.lua → tetris/rulesets/standard_ace.lua
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
local Ruleset = require 'tetris.rulesets.ti_srs'
|
local Ruleset = require 'tetris.rulesets.standard_ti'
|
||||||
|
|
||||||
local SRS = Ruleset:extend()
|
local SRS = Ruleset:extend()
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
local Ruleset = require 'tetris.rulesets.arika_srs'
|
local Ruleset = require 'tetris.rulesets.standard_ti'
|
||||||
|
|
||||||
local SRS = Ruleset:extend()
|
local SRS = Ruleset:extend()
|
||||||
|
|
||||||
@@ -27,8 +27,6 @@ function SRS:checkNewLow(piece)
|
|||||||
for _, block in pairs(piece:getBlockOffsets()) do
|
for _, block in pairs(piece:getBlockOffsets()) do
|
||||||
local y = piece.position.y + block.y
|
local y = piece.position.y + block.y
|
||||||
if y > piece.lowest_y then
|
if y > piece.lowest_y then
|
||||||
--piece.manipulations = 0
|
|
||||||
--piece.rotations = 0
|
|
||||||
piece.lowest_y = y
|
piece.lowest_y = y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user