
-----------------------------------
markEGz
Sun Mar 12, 2006 1:38 am

need help on decreasin speed
-----------------------------------
Hi i got a real quick question - my class started turing about 3 weeks ago, their only on loopin n all but im jumpin kinda ahead and making progress on my own...

My project is to make a racing game -

Ive made the tracks aleady beeing looped so the car looks like its moving

Basicly the border or the "sdie where the car cant go out of" looks like ..
"*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****"

Ive made it look like its moving by simply removing one * from the left and a symbol from the right side etc.. 

Ive also used arrow keys for movement

My Question was if any of you guys had an idea how i could make when i release my forward arrow key the borders dont just suddently stop moving but slowly make it look like the car is decreasing speed
((( Maybe the key is to tell the comp when the key is NOT beeing pressed ... but got confused on how to exactly specify that cmd)))
thanks alot, and if you need more info on how ive put it together please ask :) thx again

-----------------------------------
cool dude
Sun Mar 12, 2006 10:22 am


-----------------------------------

Ive made it look like its moving by simply removing one * from the left and a symbol from the right side etc.. 

i hadn't seen your code, and it would help if u post it but from wat i can see u have the * getting removed so why don't u say in your code if the up arrow has no value then put a delay on the astricks(*) disapearing. please post your code though so i can be more of help :)

-----------------------------------
Delos
Sun Mar 12, 2006 10:27 am


-----------------------------------
Hello and welcome.

Glad to hear that you're stepping forward and doing some independant learning.  We'll come back to that soon.

A couple of quick netiquette rules:  generally, when you post up a question it's a good idea to either include the code in 
% This is just pseudo-code!
if left-arrow is pressed and counter is less than max-value then
  increase value of counter
if left-arrow is not pressed and counter is greater than zero then
  decrease value of counter

change coordinate values of object
draw object


Back to the independant learning:  check out the tuts I mentioned.  To get through a lot of these concepts you'll need a fairly good knowledge of how loops and if-structures work.  From there, I would suggest you moving on to records and types, but first get this down.
Post up some code when it's done so we can see how you've progressed.

-----------------------------------
markEGz
Sun Mar 12, 2006 1:46 pm


-----------------------------------
oh very sorry ^_^

well here is my code --> i've changed the border count for each just to simply show how it working and no confusion this time :)


                                
            if BorderCount = 0 then
              BorderHigher := "*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****"
            elsif BorderCount = 1 then
              BorderHigher := "****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-"
            elsif BorderCount = 2 then
              BorderHigher := "***-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~"
            elsif BorderCount = 3 then
              BorderHigher := "**-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-"
            elsif BorderCount = 4 then
              BorderHigher := "*-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~" 
            elsif BorderCount = 5 then         
              BorderHigher := "-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-"
            elsif BorderCount = 6 then          
              BorderHigher := "~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~"
            elsif BorderCount = 7 then
              BorderHigher := "-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-"
            elsif BorderCount = 8 then
              BorderHigher := "~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~"
            elsif BorderCount = 9 then
              BorderHigher := "-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-"
            elsif BorderCount = 10 then
              BorderHigher := "~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~"
            elsif BorderCount = 11 then
              BorderHigher := "-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~*"
            elsif BorderCount = 12 then
              BorderHigher := "~-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~**"
            elsif BorderCount = 13 then
              BorderHigher := "-~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~***"
            elsif BorderCount = 14 then
              BorderHigher := "~*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~****"
            elsif BorderCount = 15 then
              BorderHigher := "*****~-~-~-~-~-*****-~-~-~-~-~*****~-~-~-~-~-*****-~-~-~-~-~*****-~-~-~-~-~*****"
           end if
         

       if BorderCount >= 0 then
       put x
       put BorderCount
       put Plus15numberCount
       put DelaySpeed
       put BRIGHTIDEAMAN
       put ""
       put ""
       put BorderHigher
       put ""
       put ""
       put ""
       put ""
       put ""                                         % Sets the screen for Borders
       put ""
       put ""
       put ""
       put ""
       put ""
       put ""
       put ""
       put ""
       put ""
       put ""
       put BorderHigher
       end if
      


Having said that, heres the code for my forward (which is actualy the right key because the game is left - right view not up - down)


if MoveAcrossBlockOneRIGHTs1 = true and chars (KEY_RIGHT_ARROW) then
                x:=x+5
                CheckSpeed := false            
             else
                x:=100
                Plus15numberCount:=0
                DelaySpeed:=DelaySpeed+10
                SpeedUpNumberCount:=0
            end if
            
                if DelaySpeed >= 200 then
                DelaySpeed := 200
                end if
 ( there might be shorter ways to do it but im still learning so as long as i get the concept il change to  make it mroe efficient after). So as you see, the x value keeps increasing. It is the only value which doesnt change the cordinates for the car but it only moves the borders on the screen, otherwise the car will always be going out of the picture)

Now, my DelaySpeed max is 200. Whenever the right key is not beeing pressed i reset everything to what the car started off before ( exept delay time doesnt go to 200 right away, instead decrease by 10 so if u tap your right key it looks as if your lossing, picking up speed)

Knowing how my delaytime works, my borders basicaly loop through and 1 bordercount = 15 cordercount. 

Now, what i wanted to do is somehow, when i release my forwardkey ( right key ) my delayspeed starts increasing ( as i already did ) and i wanted the borders depending on which delayspeed is start going on oppositve direction. Example - If i am going non stop and my delay speed is at minimum already(means car is going at fastest speed which is 8) and i let go of my right key - the bordercount stops but instead i want to make it decrease. - the exit of that loop to be made will basicly be when delaytime = 200 then stop the bordercount count down. The problems ive had were that if when the car stops border coutn is 1 then it gotta decrease 1 - 0 - 15 - 14 and so on. So i hope ive been a little more clear this time and i really appriciate if you guys help me out :)

-----------------------------------
MysticVegeta
Sun Mar 12, 2006 3:53 pm


-----------------------------------
wow have you ever heard of loops? Thats just crazy pseudo code in the beginning there, why dont you firsyt simplify it, then repost the code?

-----------------------------------
cool dude
Sun Mar 12, 2006 5:13 pm


-----------------------------------
wow have you ever heard of loops? Thats just crazy pseudo code in the beginning there, why dont you firsyt simplify it, then repost the code?

not only that. if u read wat Delos wrote u would have see make sure the code runs!!! u have to declare your variables and i'm not goin to sit there and declare all of them on my own so do that and repost. as well u could really really use loops as mysticVegeta said. its a waste of time to write all that code out when it could be condensed to 5 times smaller

-----------------------------------
Delos
Mon Mar 13, 2006 8:55 am


-----------------------------------
Hmm...three weeks of Turing and no loops?!  Either your teacher is very slow or your class is...:lol:.  Either way, the others are quite right.  You really should have adherred to the guidlines I mentioned, and if you don't know loops yet - go learn them from the Tuts.

-----------------------------------
cool dude
Mon Mar 13, 2006 11:38 am


-----------------------------------
this is the deal. i'll help u on two conditions

1)make better variable names and INITIALIZE them because the program crashes (READ Delos post about your program running and not crashing)

2)Declare all your variables so the program will run!!!

-----------------------------------
Clayton
Wed Mar 15, 2006 5:19 pm


-----------------------------------
wow, um when ur righting code make sure to comment some of the parts for example, when ur declaring ur variables make sure to, either in the names of the variable itself or with a comment, what that variable does, for example, wut does BorderHigher do and wut is it for?? also look into loops in the Turing Walkthrough, they will help u GREATLY!!!! that code u posted could have been shortened by about a bajillion lines if u loop a couple parts in it. also make sure that if the code will run without at least major changes in it, or if it doesnt run it better be easy to read and should be able to be understood easily so that the debugger looking at it can actually visualize wut is going or supposed to happen on the screen and wut it should look like graphically (if req'd) this is all mentioned in Delos' post above so please read this and think about it and you will make everyones life easier
