Discord
Login
Community
DARK THEME

Can somoan help me i making a game where there is an ai and you are the ball and you need to play pong the bat is the ai

thise is the code used withe Quick engine:

ballMove = function() collision = Quick.spriteCollision(ball, ai)

if keyboard.DOWN or gamepad.DOWN then ball.vy = -100 end

if keyboard.LEFT or gamepad.LEFT then ball.vx = -100 end

if keyboard.RIGHT or gamepad.RIGHT then ball.vx = 100 end

if not collision and ball.grounded then ball.vy = 100 score += 1 end

end

i dont understand why the score goes up even when i said if not collision and ball.grounded

The character next to key 1 on the keyboard 3 times causes the text to be treated as program code and is not formatted.

The grounded property in Quick is assigned to an object when it stands on something (it has a collision with a tile or is on the ground).

ballMove = function() 
   collision = Quick.spriteCollision(ball, ai)

   if keyboard.DOWN or gamepad.DOWN then ball.vy = -100 end
  
   if keyboard.LEFT or gamepad.LEFT then ball.vx = -100 end

   if keyboard.RIGHT or gamepad.RIGHT then ball.vx = 100 end 

   if collision then ball.vy = 100 score += 1 end

end

thank you

Post a reply

Progress

Status

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