Page 1 of 1

Undone changes but still wont run?

Posted: Thu Dec 08, 2011 12:26 am
by danGAHRIh
Hi,
Only been using LiveCode for about two hours and very new to this, have some php and asp experience but that's about it.

I am following the rocket game introduction lessons and managed to get the rocket to go up and down when the mouse was down and not down.

I then set up a global variable myspeed and added 1 to myspeed each update and the little rocket rapidly sped up and shot to the bottom. All was working, ITS ALIVE!!!! :)

I then tried to get clever and add a max to myspeed - so I added IF myspeed was > 10 then nothing, else do the last bit of code - add the 1 to myspeed to get a maximum speed but I spelt the "else" as "eelse" so it didn't work, I quickly changed it back to "else" and it still didn't work, so I undid adding the last "if myspeed > 10" to go back to the code that was working a few minutes ago but the little rocket still wont move! All I did was click undo a couple of times.

I have tried undoing back more to see if I can just get the rocket to drop but its not working. I have re-done the changes and adjusted the code lots now trying to make it work but I have screwed up the engines on the little rocket ship. It seems as if I need to reset or make it forget about the maximum speed variable "eelse" spelling mistake but I don't know what to do.

Can someone help? Thank you very much in advance!!! :mrgreen:

Code: Select all


local sGameRunning
global myspeed 
put 1 into myspeed

on updatescreen
   
   if sGameRunning then
      
      if the mouse is not down then 
         
         if the bottom of image "rocket"  +50 < the bottom of this card then 
            set the top of image "rocket" to the top of image "rocket" + myspeed      
         end if
      else
         if the top of image "rocket" > the top of this card then 
            set the top of image "rocket" to the top of image "rocket" - 10
         end if 
         
      end if
      
   end If
   
   
end updatescreen

on startGame
   activateScreenUpdates 
         put true into sGameRunning
end startgame

on stopgame
   put false into sGameRunning
   set the top of image "rocket" to the top of this card
end stopgame

Re: Undone changes but still wont run?

Posted: Thu Dec 08, 2011 12:49 am
by bn
Hi Dan,

Welcome to the Forum.

one thing I see is that you try to put 1 into the global variable mySpeed outside of any handler. That does not work. You correctly placed the declaration of the global mySpeed outside of any handler (which means in between on xxx and end xxx). Also the script local varible is correctly declared.

Probably the "put 1 into mySpeed" is a leftover from some of the undos. Put it within an appropriate handler, like initialization or some such and it will work.

Furthermore

Code: Select all

 set the top of image "rocket" to the top of image "rocket" + myspeed  
looks funny. You add whatever is in myspeed to the top???

maybe more is missing. Isn't there supposed to be a section in the forum for the game academy? They should know more about it.

Kind regards

Bernd

Re: Undone changes but still wont run?

Posted: Thu Dec 08, 2011 1:02 am
by danGAHRIh
Hey Bernd,

Thanks for your reply, Yes your right, I just clicked the email link again for the forum and it took my right there!
The myspeed variable thing was just me playing, that was just "10" before I messed with it. The bit under the variable declaration was me trying to set the myspeed to 1 right at the start of the code :? . I've stripped it right back to the code below and it still doesn't work. :( I will go to the game academy room and have a chat in there.

Code: Select all

local sGameRunning

on updatescreen
   
   if sGameRunning then
      if the mouse is not down then 
            set the top of image "rocket" to the top of image "rocket" + 10        
      end if
   end If
   
   
end updatescreen

on startGame
   activateScreenUpdates 
   put true into sGameRunning

end startgame

on stopgame
   put false into sGameRunning
   set the top of image "rocket" to the top of this card
end stopgame

Thanks :D

Re: Undone changes but still wont run?

Posted: Thu Dec 08, 2011 1:15 am
by danGAHRIh
Not sure what it was, but I just closed that file and re-loaded the old saved version I had, there weren't many changes to get back to where I was and this is the code I have that is working........ woohoo! Gravity with maximum velocity. Onwards and upwards! Thanks for your help Bernd! :D

Code: Select all

local sGameRunning
global myspeed 

on updatescreen
   
   if sGameRunning then
      
      if the mouse is not down then 
         
         if the bottom of image "rocket"  +50 < the bottom of this card then 
            if myspeed < 10 then 
               add 0.1 to myspeed
               end if
            set the top of image "rocket" to the top of image "rocket" + myspeed      
         end if
      else
         if the top of image "rocket" > the top of this card then 
            set the top of image "rocket" to the top of image "rocket" - 10
         end if 
         
      end if
      
   end If
   
   
end updatescreen

on startGame
   activateScreenUpdates
   
      put true into sGameRunning
end startgame

on stopgame
   put false into sGameRunning
   set the top of image "rocket" to the top of this card
   put 1 into myspeed
end stopgame