How I can make my ball stand in the middle of my racket?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Bernard51
Prole
Posts: 46
Joined: Fri Jan 20, 2017 5:51 pm

How I can make my ball stand in the middle of my racket?

Post by Bernard51 »

Hello
How I can make my ball stand in the middle of my racket?
please

thank you

https://www.dropbox.com/s/gm28erfiikq25 ... 2.zip?dl=0
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How I can make my ball stand in the middle of my racket?

Post by raidho36 »

Code: Select all

if ball_should_stick then
  ball.x = racket.x + 12
  ball.y = racket.y + 34
end
Didn't check your code.
Bernard51
Prole
Posts: 46
Joined: Fri Jan 20, 2017 5:51 pm

Re: How I can make my ball stand in the middle of my racket?

Post by Bernard51 »

thank you Of your answer

How I can do now so that my ball is glued to the racket ?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How I can make my ball stand in the middle of my racket?

Post by raidho36 »

In the first line of the example I posted, there's a conditional statement. It checks if expression between "if" and "then" evaluates to "true". If you have this variable set to "false" then it will not activate sticking code, if it's set to true - it will.
Bernard51
Prole
Posts: 46
Joined: Fri Jan 20, 2017 5:51 pm

Re: How I can make my ball stand in the middle of my racket?

Post by Bernard51 »

Thank you

If I add it it does not work the ball does not stick :

Code: Select all

 if  balle_should_stick and balle.colle == true  then
       balle.x = raquette.x + 12
       balle.y = raquette.y + 34
    
   end  
At the beginning of the code I put:
-- La balle
local balle = {}
balle.x = 420
balle.y = 550
balle.colle = false
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How I can make my ball stand in the middle of my racket?

Post by raidho36 »

The "balle_should_stick" is a made-up variable that you substitute with something on your own, it controls whether ball should stick or not. You have there "balle.colle" so you probably don't need that first one. Also since you never set it to anything, it evaluates to "false". You should just remove "balle_should_stick".
Bernard51
Prole
Posts: 46
Joined: Fri Jan 20, 2017 5:51 pm

Re: How I can make my ball stand in the middle of my racket?

Post by Bernard51 »

If I do that, it does not work I have more ball

Code: Select all

   if  balle.colle == true  then
       balle.x = raquette.x + 12
       balle.y = raquette.y + 34
    
   end  
  
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 54 guests