Log In  


Cart #zimemedagu-0 | 2023-12-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3


Hi everyone, attached here is a current game I'm working on.
Its just a simple concept game with a theme of focus ie avoiding invasive thoughts while meditating. Just move left and right. But also can shoot if player getting board of avoiding the meteors

2 questions:
1- I put a timer and how to print the last time when the game stopped?
In this case, the stopwatch kept running after the game ended.

2- I'm trying to use a 16x16 main sprite player, I'm not sure the code how to display the player icon to display the 16x16pixels, it only displays the 8x8 pixels

Thank you so much in advance

3


1

I'll take your question in reverse order:

  1. The spr function takes an optional width and height (in tiles, not pixels) so if your sprite is sprite #1 you'd do this:
    spr(1, x, y, 2, 2)

Where x and y are the screen coordinates where you want to draw it. Two tiles is 16 pixels so 2x2 tiles is 16x16 pixels just like you want.

  1. When you get hit and the game ends the game doesn't know that it's ended. In your _update function you're always adding 1 to the counter no matter what and so it keeps running even once the game "ends."

What you want to do is put it inside an if statement:

if not gameover then
  countdown_timer += 1
end

In your _init function you can initially set gameover = false and then when the player gets hit you set gameover = true and your timer should stop running.

Hope that helps!


1

Thank you so much Jason for the very quick response and help. I'll update the game. Thank you.



[Please log in to post a comment]