This is my first time making game. I decided to make grid like game and encountered several issues i hope someone can help me with:
1. My random number generator generates numbers to fast, making computer cube move like a missile. I guess its due to being in update function and updates happening very rapidly, is there any way to slow it down, that computer cube is moving slower ?
2. How to create victory/ defeat screen ? What i want is, after collision with computer or collision with eXit cube for victory/ defeat screen to appear, i tried it in DefeatScreen() function but nothing happens, is there any way to do it and make it stay while appropriate action is made ? In this case space to retry, escape to exit.
3. Is there any way to make explosion like sprites appear when collision happen and stay for a sec or two before defeat screen rolls in ?
Any advice on game or help about issues would be appreciated!
I have added my code in love zip file.
How to slow down number generator, create victory screen ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to slow down number generator, create victory screen ?
- Attachments
-
- cubegame.zip
- (1.14 KiB) Downloaded 59 times
Re: How to slow down number generator, create victory screen
1. You can use a simple timer for that.
In love.load():
in love.update()
Of course you can name the variables whatever you want. But this will run whatever code you put after the if statement roughly every second.
2. You can do that with gamestates. Basically you would have a variable called "gamestate" or something like that and based on the variables value you would draw/update different things.
You could do that in love.draw() and love.update() (if you need to update anything in the gameover state that is), And love.keypressed() for the retry and exit keys. When the state is "game" and collision with the computer occurs you would set the gamestate to "gameover", and when the retry key is pressed you would set it back to "game", Also you would have to reset any variables such as score etc.
3. That can be done with a timer like i mentioned above.
In love.load():
Code: Select all
tick = 0
interval = 1
Code: Select all
tick = tick + dt
if tick > interval then
--Random number code goes here
tick = 0
end
2. You can do that with gamestates. Basically you would have a variable called "gamestate" or something like that and based on the variables value you would draw/update different things.
Code: Select all
if gamestate == "game" then
--Game code
elseif gamestate == "gameover" then
--Game over code
end
3. That can be done with a timer like i mentioned above.
Re: How to slow down number generator, create victory screen
Thank you veethree, your advice helped me fix all problems. Solutions were so simple, i cant believe i didnt think of them....
Anyway thanks.
Anyway thanks.
Who is online
Users browsing this forum: No registered users and 4 guests