Discord
Login
Community
DARK THEME

Progress bar

can someone help add a progress bar to my game. That counts down and when it hets to 0 it runs a function and im useing Quick engine if thats helps. Its sposted to be like a fuel bar for the jetpack in my game.

game link https://microstudio.dev/i/pgmz5/ogmz5s/

BTW co-dev is pgmz5

plesss help

Player = class
  constructor = function()
    this.sprite = Quick.addSprite("bobhover",0,0,16,24)
    this.progressbar = new bar( 1000, 100, "bar2")
  end
  
  state = function( mode )
    if this.sprite.name == "bobhover" and mode then 
        this.sprite.name = "bobfly"
    else
      if not mode and this.sprite.name == "bobfly" then 
        this.sprite.name = "bobhover"
      end
    end
    if mode then 
      Quick.camera.shake = 0.7
      this.sprite.ay = 450
    else
      Quick.camera.shake = 0.00
    end
  end
  
  draw = function()
    this.progressbar.progress = random.nextInt( 1000 )
    this.progressbar.updateBar()
    this.progressbar.drawBar( 0, 50, 50 * Quick.camera.zoom, 5 * Quick.camera.zoom, system.time()/60%360 )
  end
end

init = function()
  LevelDev = 0
  Quick.init()
  Quick.ground = -50000000
  Quick.gravity = 25
  Quick.camera.zoom = 3
  Quick.friction =  5
  control_help = Quick.addText("Use LEFT or RIGHT arrows to move",0,-30,5,5)
  control_help_2 = Quick.addText("Use UP arrow to use the jetpack",0,-39,5,5)
  help = Quick.addText("<  <  <  Keep going",40,150,5,5)
  arrow = Quick.addText(">  >  >",20,-49,5,5)
  arrow_2 = Quick.addText("^",85,-50,20,20)
  arrow_2 = Quick.addText("^",85,-35,20,20)
  arrow_2 = Quick.addText("^",85,-20,20,20)
  arrow_2 = Quick.addText("^",85,100,20,20)
  arrow_2 = Quick.addText("^",85,85,20,20)
  arrow_2 = Quick.addText("^",85,70,20,20)
  lvl_1 = Quick.addMap("map",0,150,500,500)
  endlevel = Quick.addSprite("end",-144,170,25,60)
  endlevel.fixed = 1
  endlevel.solid = 0
  //lvl2
  //lvl_2 =  Quick.addMap("map2",500,150,500,500)
  coin = endlevel = Quick.addSprite("coin",272,33,25,25)
  player = new Player()
end

update = function()
  //in init set LevelDev to 1 when making levels
  //when not making levels or in dev set to 0
    if LevelDev == 1 then
    if keyboard.S then
      lvl_1.solid = 0
      lvl_2.solid = 0
    end
    if keyboard.D then
      lvl_1.solid = 1
      lvl_2.solid = 1
    end
  end
  // other stuff
  if keyboard.R then
    player.sprite.y = 0
    player.sprite.x = 0
  end
  if keyboard.LEFT then
      player.sprite.hflip = 1
      player.sprite.vx -= 5
  end
  if keyboard.RIGHT then
    player.sprite.hflip = 0
    player.sprite.vx += 5
  end
  if Quick.spriteCollision(endlevel,player.sprite) then
    print("end")
    player.sprite.x = 0
    player.sprite.y = 0
  else
    print(round(player.sprite.y)+" y, "+ round(player.sprite.x)+" x")
  end
  player.state( keyboard.UP )
  Quick.camera.move( player.sprite.x, player.sprite.y )
  Quick.update()
end
draw = function()
  Quick.draw() 
  player.draw()
  CRT(1000, 0.5,5) 
  //CRT(no of lines,intensity,speed)
end

You need to have a sprite with 3 frames of animation.

Copy from the library example if you don't have such sprites.

I think it would be good to modify Quick Engine so that, for example, complex objects would be rendered according to the draw method they would have.

TYSM. btw the L on the coin in our game stands for Loginus because you have help so much. Can i put you in the credits?

Why does it rotate?

can i have more then 3 frames?

the library you used to draw the progressbar uses Sprite which has 3 frames.

  • the first one is the background (it can be a blue texture)
  • the second is a bar that grows (e.g. red rectangle)
  • the third one is a mask that will be applied to the previous two and should be largely transparent (otherwise it will cover the previous two).

The bar rotates because the library has the option of drawing this bar at different angles of inclination. Remove this code and it won't rotate.

system.time()/60%360 
this.progressbar.drawBar( 0, 50, 50 * Quick.camera.zoom, 5 * Quick.camera.zoom, 0 )

Advice on the forum is not enough to be included in the credits.

nothing i did yesterday saved. this is bad. because i have a deadline. im showing the game at a convention/tech showcase and the game doesnt work. collisions between the player and objects like coins that are sposed to run code like add to a variable isnt working but i fixed it yesterday. but it didnt save. do i have to click save or somwthing????????????

nothing i did yesterday saved. this is bad. because i have a deadline. im showing the game at a convention/tech showcase and the game doesnt work. collisions between the player and objects like coins that are sposed to run code like add to a variable isnt working but i fixed it yesterday. but it didnt save. do i have to click save or somwthing????????????

Maybe you had a problem with the internet.

To be sure, if your project is very important, export the project to your computer from time to time.

ok tysm. btw scince youve been such a good help i want to put you in the credits. the "L" on the coin is named after you and the story is that a cat got solen and you have to save your cat. you chose what the stolen cats name is. it could be Loginus or whatever you want.

thx angin so much @Loginus you have been a major help will defenetly be one of the main devs in the credits

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community