racing_stat_prototype #2

Merged
fnicon merged 4 commits from racing_stat_prototype into main 2026-03-13 15:04:14 +00:00
2 changed files with 59 additions and 1 deletions
Showing only changes of commit dbdf338f3e - Show all commits

View File

@ -1,3 +1,13 @@
local racing = require("src.modes.racing")
function love.load() function love.load()
print("hello") racing.load()
end
function love.update(dt)
racing.update(dt)
end
function love.draw()
racing.draw()
end end

48
game/src/modes/racing.lua Normal file
View File

@ -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