From dbdf338f3e5d3065519168b801082e205a61f9c9 Mon Sep 17 00:00:00 2001 From: fnicon Date: Fri, 13 Mar 2026 21:55:43 +0900 Subject: [PATCH 1/4] add simple start - finish movement --- game/main.lua | 12 +++++++++- game/src/modes/racing.lua | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 game/src/modes/racing.lua diff --git a/game/main.lua b/game/main.lua index 9d7cd2c..23fb53b 100644 --- a/game/main.lua +++ b/game/main.lua @@ -1,3 +1,13 @@ +local racing = require("src.modes.racing") + function love.load() - print("hello") + racing.load() +end + +function love.update(dt) + racing.update(dt) +end + +function love.draw() + racing.draw() end diff --git a/game/src/modes/racing.lua b/game/src/modes/racing.lua new file mode 100644 index 0000000..9c585b8 --- /dev/null +++ b/game/src/modes/racing.lua @@ -0,0 +1,48 @@ +local mode = {} + +local finish = {100, 100, 0} + +local entities = { + racer = { + pos = {0, 100, 0}, + color = {255/255, 255/255, 255/255}, + + race_stats = { + max_speed = 100, + speed = 2, + accel = 10, + + }, + + draw = function (self) + love.graphics.push() + love.graphics.setColor(self.color[1], self.color[2], self.color[3]) + love.graphics.points(self.pos[1], self.pos[2]) + + love.graphics.print(self.race_stats.speed, self.pos[1], self.pos[2]) + + love.graphics.pop() + end, + + update = function (self, dt) + if (self.pos[1] > finish[1]) then + self.pos[1] = 0 + end + self.pos[1] = self.pos[1] + self.race_stats.speed * dt + end + } +} + +function mode.load() + +end + +function mode.update(dt) + entities.racer:update(dt) +end + +function mode.draw() + entities.racer:draw() +end + +return mode -- 2.49.0 From a4576b4233ea4650d632f8fcd8a20b4763151a4a Mon Sep 17 00:00:00 2001 From: fnicon Date: Fri, 13 Mar 2026 22:10:51 +0900 Subject: [PATCH 2/4] add accel and max speed --- game/src/modes/racing.lua | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/game/src/modes/racing.lua b/game/src/modes/racing.lua index 9c585b8..581017a 100644 --- a/game/src/modes/racing.lua +++ b/game/src/modes/racing.lua @@ -8,10 +8,10 @@ local entities = { color = {255/255, 255/255, 255/255}, race_stats = { - max_speed = 100, - speed = 2, - accel = 10, - + max_speed = 100.0, + accel = 2.0, + current_speed = 2.0, + current_accel = 0.0, }, draw = function (self) @@ -19,16 +19,31 @@ local entities = { love.graphics.setColor(self.color[1], self.color[2], self.color[3]) love.graphics.points(self.pos[1], self.pos[2]) - love.graphics.print(self.race_stats.speed, self.pos[1], self.pos[2]) + love.graphics.print(self.race_stats.current_speed, self.pos[1], self.pos[2]) + love.graphics.print(string.format("Max Speed : %s", self.race_stats.max_speed), 0, 0) + love.graphics.print(string.format("Accel : %s", self.race_stats.accel), 0, 20) + love.graphics.print(string.format("Current Accel : %s", self.race_stats.current_accel), 0, 40) love.graphics.pop() end, update = function (self, dt) if (self.pos[1] > finish[1]) then self.pos[1] = 0 + self.race_stats.current_speed = 0 + self.race_stats.current_accel = 0 + end + self:accel(dt) + self.pos[1] = self.pos[1] + self.race_stats.current_speed * dt + end, + + accel = function(self, dt) + if (self.race_stats.current_accel <= self.race_stats.accel) then + self.race_stats.current_accel = self.race_stats.current_accel + dt + end + if (self.race_stats.current_speed <= self.race_stats.max_speed) then + self.race_stats.current_speed = self.race_stats.current_speed + self.race_stats.current_accel end - self.pos[1] = self.pos[1] + self.race_stats.speed * dt end } } -- 2.49.0 From 6e5f0f202945dc0b2a6a9b71fce44c3b309a08ac Mon Sep 17 00:00:00 2001 From: fnicon Date: Fri, 13 Mar 2026 22:33:20 +0900 Subject: [PATCH 3/4] add mode switch --- game/main.lua | 31 +++++++++++++++++++++++++++---- game/src/modes/mode.lua | 24 ++++++++++++++++++++++++ game/src/modes/racing.lua | 9 +++++++++ game/src/modes/raising_sim.lua | 28 ++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 game/src/modes/mode.lua create mode 100644 game/src/modes/raising_sim.lua diff --git a/game/main.lua b/game/main.lua index 23fb53b..ac4d1ee 100644 --- a/game/main.lua +++ b/game/main.lua @@ -1,13 +1,36 @@ -local racing = require("src.modes.racing") +local mode = { + require("src.modes.racing"), + require("src.modes.raising_sim") +}; + +local mode_i = 1 function love.load() - racing.load() + mode[mode_i].load() end function love.update(dt) - racing.update(dt) + mode[mode_i].update(dt) end function love.draw() - racing.draw() + mode[mode_i].draw() +end + +function love.keyreleased(key, scancode) + if (key == "right") then + mode_i = mode_i + 1 + if (mode_i > 2) then + mode_i = 1 + end + end + mode[mode_i].keyreleased(key, scancode) +end + +function love.keypressed(key, scancode, isrepeat) + mode[mode_i].keypressed(key, scancode, isrepeat) +end + +function love.mousereleased(x, y, button, istouch, presses) + mode[mode_i].mousereleased(x, y, button, istouch, presses) end diff --git a/game/src/modes/mode.lua b/game/src/modes/mode.lua new file mode 100644 index 0000000..7e3169d --- /dev/null +++ b/game/src/modes/mode.lua @@ -0,0 +1,24 @@ +local mode = {} + + +function mode.load() + +end + +function mode.update(dt) +end + +function mode.draw() +end + +function mode.keyreleased(key, scancode) +end + +function mode.keypressed(key, scancode, isrepeat) +end + +function mode.mousereleased(x, y, button, istouch, presses) +end + + +return mode diff --git a/game/src/modes/racing.lua b/game/src/modes/racing.lua index 581017a..f2a8a40 100644 --- a/game/src/modes/racing.lua +++ b/game/src/modes/racing.lua @@ -60,4 +60,13 @@ function mode.draw() entities.racer:draw() end +function mode.keyreleased(key, scancode) +end + +function mode.keypressed(key, scancode, isrepeat) +end + +function mode.mousereleased(x, y, button, istouch, presses) +end + return mode diff --git a/game/src/modes/raising_sim.lua b/game/src/modes/raising_sim.lua new file mode 100644 index 0000000..6d98dd8 --- /dev/null +++ b/game/src/modes/raising_sim.lua @@ -0,0 +1,28 @@ +local mode = {} + +local entities = { + +} + + +function mode.load() + +end + +function mode.update(dt) +end + +function mode.draw() +end + +function mode.keyreleased(key, scancode) +end + +function mode.keypressed(key, scancode, isrepeat) +end + +function mode.mousereleased(x, y, button, istouch, presses) +end + + +return mode -- 2.49.0 From 2e54e144ceb26d597d1c396bda754dc06e6c1abc Mon Sep 17 00:00:00 2001 From: fnicon Date: Fri, 13 Mar 2026 23:52:22 +0900 Subject: [PATCH 4/4] add stat raising sim mode --- game/main.lua | 6 +++- game/src/entities/racing/racer.lua | 49 +++++++++++++++++++++++++ game/src/entities/raising/trainee.lua | 41 +++++++++++++++++++++ game/src/entities/shared/actor.lua | 26 ++++++++++++++ game/src/modes/mode.lua | 2 +- game/src/modes/racing.lua | 52 +++------------------------ game/src/modes/raising_sim.lua | 15 ++++---- 7 files changed, 136 insertions(+), 55 deletions(-) create mode 100644 game/src/entities/racing/racer.lua create mode 100644 game/src/entities/raising/trainee.lua create mode 100644 game/src/entities/shared/actor.lua diff --git a/game/main.lua b/game/main.lua index ac4d1ee..a1a5d59 100644 --- a/game/main.lua +++ b/game/main.lua @@ -3,10 +3,13 @@ local mode = { require("src.modes.raising_sim") }; +local actor = require("src.entities.shared.actor") +local player = actor.load("player") + local mode_i = 1 function love.load() - mode[mode_i].load() + mode[mode_i].load(player) end function love.update(dt) @@ -23,6 +26,7 @@ function love.keyreleased(key, scancode) if (mode_i > 2) then mode_i = 1 end + mode[mode_i].load(player) end mode[mode_i].keyreleased(key, scancode) end diff --git a/game/src/entities/racing/racer.lua b/game/src/entities/racing/racer.lua new file mode 100644 index 0000000..ef33feb --- /dev/null +++ b/game/src/entities/racing/racer.lua @@ -0,0 +1,49 @@ +local entity = {} + +entity.__index = entity + +function entity.load(actor, finish) + local self = setmetatable({}, entity) + self.data = { + pos = {0, 100, 0}, + color = {255/255, 255/255, 255/255}, + actor = actor, + + current_speed = 0.0, + current_accel = 0.0, + + finish = finish + } + return self +end + +function entity:update(dt) + if (self.data.pos[1] > self.data.finish[1]) then + self.data.pos[1] = 0 + self.data.current_speed = 0 + self.data.current_accel = 0 + end + self:accel(dt) + self.data.pos[1] = self.data.pos[1] + self.data.current_speed * dt +end + +function entity:accel(dt) + if (self.data.current_accel <= self.data.actor.data.accel) then + self.data.current_accel = self.data.current_accel + dt + end + if (self.data.current_speed <= self.data.actor.data.max_speed) then + self.data.current_speed = self.data.current_speed + self.data.current_accel * dt + end +end + +function entity:draw() + love.graphics.push() + love.graphics.setColor(self.data.color[1], self.data.color[2], self.data.color[3]) + love.graphics.points(self.data.pos[1], self.data.pos[2]) + love.graphics.print(self.data.current_speed, self.data.pos[1], self.data.pos[2]) + love.graphics.print(string.format("Current Accel : %s", self.data.current_accel), 0, 40) + love.graphics.pop() + self.data.actor:draw() +end + +return entity diff --git a/game/src/entities/raising/trainee.lua b/game/src/entities/raising/trainee.lua new file mode 100644 index 0000000..c7f8cb1 --- /dev/null +++ b/game/src/entities/raising/trainee.lua @@ -0,0 +1,41 @@ +local entity = {} + +entity.__index = entity + +function entity.load(actor) + local self = setmetatable({}, entity) + self.data = { + actor = actor, + + increase_max_speed = 1, + increase_accel = 1 + } + return self +end + +function entity:update(dt) + +end + +function entity:draw() + love.graphics.push() + love.graphics.print(string.format("[(a)-Max Speed+(d)] : %s", self.data.increase_max_speed), 0, 40) + love.graphics.print(string.format("[(q)-Accel+(e)] : %s", self.data.increase_accel), 0, 60) + love.graphics.pop() + self.data.actor:draw() +end + +function entity:keyreleased(key, scancode) + if (key == "a") then + self.data.actor.data.max_speed = self.data.actor.data.max_speed - self.data.increase_max_speed + elseif (key == "d") then + self.data.actor.data.max_speed = self.data.actor.data.max_speed + self.data.increase_max_speed + elseif (key == "q") then + self.data.actor.data.accel = self.data.actor.data.accel - self.data.increase_accel + elseif (key == "e") then + self.data.actor.data.accel = self.data.actor.data.accel + self.data.increase_accel + end +end + + +return entity diff --git a/game/src/entities/shared/actor.lua b/game/src/entities/shared/actor.lua new file mode 100644 index 0000000..fc4d4de --- /dev/null +++ b/game/src/entities/shared/actor.lua @@ -0,0 +1,26 @@ +local entity = {} + +entity.__index = entity + +function entity.load(name) + local self = setmetatable({}, entity) + self.data = { + max_speed = 100.0, + accel = 2.0, + } + return self +end + +function entity:update(dt) +end + +function entity:draw() + love.graphics.push() + love.graphics.print(string.format("Max Speed : %s", self.data.max_speed), 0, 0) + love.graphics.print(string.format("Accel : %s", self.data.accel), 0, 20) + love.graphics.pop() +end + + + +return entity diff --git a/game/src/modes/mode.lua b/game/src/modes/mode.lua index 7e3169d..52cc2da 100644 --- a/game/src/modes/mode.lua +++ b/game/src/modes/mode.lua @@ -1,7 +1,7 @@ local mode = {} -function mode.load() +function mode.load(player) end diff --git a/game/src/modes/racing.lua b/game/src/modes/racing.lua index f2a8a40..e00d3ed 100644 --- a/game/src/modes/racing.lua +++ b/game/src/modes/racing.lua @@ -1,55 +1,13 @@ +local racer = require("src.entities.racing.racer") + local mode = {} local finish = {100, 100, 0} -local entities = { - racer = { - pos = {0, 100, 0}, - color = {255/255, 255/255, 255/255}, - - race_stats = { - max_speed = 100.0, - accel = 2.0, - current_speed = 2.0, - current_accel = 0.0, - }, - - draw = function (self) - love.graphics.push() - love.graphics.setColor(self.color[1], self.color[2], self.color[3]) - love.graphics.points(self.pos[1], self.pos[2]) - - love.graphics.print(self.race_stats.current_speed, self.pos[1], self.pos[2]) - - love.graphics.print(string.format("Max Speed : %s", self.race_stats.max_speed), 0, 0) - love.graphics.print(string.format("Accel : %s", self.race_stats.accel), 0, 20) - love.graphics.print(string.format("Current Accel : %s", self.race_stats.current_accel), 0, 40) - love.graphics.pop() - end, - - update = function (self, dt) - if (self.pos[1] > finish[1]) then - self.pos[1] = 0 - self.race_stats.current_speed = 0 - self.race_stats.current_accel = 0 - end - self:accel(dt) - self.pos[1] = self.pos[1] + self.race_stats.current_speed * dt - end, - - accel = function(self, dt) - if (self.race_stats.current_accel <= self.race_stats.accel) then - self.race_stats.current_accel = self.race_stats.current_accel + dt - end - if (self.race_stats.current_speed <= self.race_stats.max_speed) then - self.race_stats.current_speed = self.race_stats.current_speed + self.race_stats.current_accel - end - end - } -} - -function mode.load() +local entities = {} +function mode.load(player) + entities.racer = racer.load(player, finish) end function mode.update(dt) diff --git a/game/src/modes/raising_sim.lua b/game/src/modes/raising_sim.lua index 6d98dd8..95afef6 100644 --- a/game/src/modes/raising_sim.lua +++ b/game/src/modes/raising_sim.lua @@ -1,21 +1,24 @@ + +local trainee = require("src.entities.raising.trainee") + local mode = {} -local entities = { - -} - - -function mode.load() +local entities = {} +function mode.load(player) + entities.trainee = trainee.load(player) end function mode.update(dt) + entities.trainee:update(dt) end function mode.draw() + entities.trainee:draw() end function mode.keyreleased(key, scancode) + entities.trainee:keyreleased(key, scancode) end function mode.keypressed(key, scancode, isrepeat) -- 2.49.0