Need opinion on code so far (space game)
Posted: Thu Jul 25, 2013 11:57 am
Ive been making a space combat type game in love for a while now. I would like some opinions on my code
Code: Select all
love.update(dt)
if gameState == 'play' then
game:update(dt)
elseif gameState == 'menu' then
menu:update(dt)
end
end
Would not doing the third one slow down the game or something? or is it more of different method?micha wrote:Your code looks very well organized. I had no trouble reading and understanding it.
Here are some minor suggestions:Besides that: Well done. Looks like a solid start.
- The function fireProjectile does not use dt so you don't need to pass it
- The projectiles' velocity is stored in dx and dy. I would rather call them vx and vy (for velocity). In my understanding dx = vx * dt, so dx is the actual displacement in one frame (changes with dt) while vx is the velocity (constant). But maybe that's only me.
- In the update-function you check for pressed keys and then pass them to the movePlayer function. I suggest you put the input-check directly into the movePlayer function and then put movePlayer into a function called game:update(dt). The main update function would look like this then:
Code: Select all
love.update(dt) if gameState == 'play' then game:update(dt) elseif gameState == 'menu' then menu:update(dt) end end