Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with background/collision detection
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Original




PostPosted: Thu May 07, 2009 12:32 pm   Post subject: Need help with background/collision detection

Hi, I'm new to Turing, and I'm trying to create a game where homer simpson has to eat/drink all the donuts/beers and he has to try to avoid the Flander's faces. The problem is that I cant get the beers/donuts/faces to fall as a background. Each time homer eats the donuts/beer, he gets one point. I need help on making the background and the collision detection.
Here is the code,
Thanks Razz

Turing:
process BgmSound
  Music.PlayFileLoop ("Simpsons.mp3")
end BgmSound
fork BgmSound

View.Set ("title:Da Simpsons- By: Siyavash,graphics:400,500,position:center,center")

var z, c, q, w  : int
z:=40
c:=40
q:= 50
w:= 380

var mypic1 : int := Pic.FileNew ("homer2.bmp")
        loop
         
var chars: array char of boolean
            Input.KeyDown (chars)
           
            if chars (KEY_UP_ARROW) then
                c:=c+6
                Pic.Draw (mypic1, z, c, picCopy)
            end if
            if chars (KEY_RIGHT_ARROW) then
                z:=z+6
                Pic.Draw (mypic1, z, c, picCopy)
            end if
            if chars (KEY_LEFT_ARROW) then
                z:=z-7
                Pic.Draw (mypic1, z, c, picCopy)
            end if
            if chars (KEY_DOWN_ARROW) then
                c:=c-6
                Pic.Draw (mypic1, z, c, picCopy)
            end if
           if chars (KEY_ENTER) then
           
           w:= w-1000
               delay (20)
             
         
          end if

Pic.Draw (mypic1, z, c, 0)
delay (20)
cls

drawfilloval (q, w, 25, 25, red)
drawfilloval (q, w, 8, 8, white)

end loop



Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Dusk Eagle




PostPosted: Thu May 07, 2009 1:52 pm   Post subject: Re: Need help with background/collision detection

First, be sure to use syntax tags when posting code here: [syntax] %code here[/syntax]. The reason you can't get your donut to fall is that you must press "Enter" before it will fall. When you press enter, it immediately falls 1000 pixels, which is far greater than the height of your window. You should probably make it fall only ~10 pixels at a time (feel free to fiddle with that number though). As for collision detection, you might want to read the tutorial here.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: