Discord
Login
Community
DARK THEME

how to make projectiles?

how to make projectiles for my game ''ghost battle''

my game for you look: https:/microstudio.io/rianstar/ghostbattle

i know have a tultorial fo mrlam but, my game style is different, and i try to do their style in my game and, just don't worked lmao

thank you for the help

bullet_file

bulletinit = function( source )
  bullet = object end
  bullet.x = source.x
  bullet.y = source.y
  bullet.facing = facing
  bullet.step = 0
  bullet.active = true
end

bulletupdate = function()
  if bullet.active then 
    bullet.step += 1
    if bullet.step > 100 then 
      bulet.active = false
    end
    bullet.x += 2 * bullet.facing
  end
end

bulletdraw = function()
  if bullet.active then 
    screen.drawSprite( "g_shot", bullet.x, bullet.y )
  end
end

main_file

update = function()
  //part of collisionsAABB
  hit = collide_AABB(ghost,red)
  
  //touchkeys for gamepad
  touchKeys.update()
  if keyboard.SPACE then 
    bulletinit( ghost )
    print("space")
  end
  bulletupdate()
  
  //this function implement clamp of map
  ghost.x = clamp(ghost.x, -170, 170)
  ghost.y = clamp(ghost.y, -90, 90)
  
  //the player moviment fuction
  ghostupdate()
  
  //function for red follow the player
  redupdate()
end

draw = function()
  screen.drawMap("map"0,0,360,200)
  screen.setDrawScale(facing,1)
  if (hit) then
    screen.drawText("colide", 0, 0, 30, "#F0A")
  else
    screen.drawText("not collide", 0, 0, 30, "AFA")
  end
  screen.drawSprite("ghost" ghost.x, ghost.y, 16, 16)
  screen.drawSprite("red" red.x, red.y, 16, 16)
  bulletdraw()
  screen.setDrawScale(1,1)
  screen.setAlpha(1)
  touchKeys.draw()
  screen.setAlpha(.5)
end

Post a reply

Progress

Status

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