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

Username:   Password: 
 RegisterRegister   
 help with collision detection and making the bullet move randomly
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shadox321




PostPosted: Wed Dec 12, 2007 8:22 pm   Post subject: help with collision detection and making the bullet move randomly

okay i need help for my game im new to turing and dont understand most of what im doing, but heres my program
var keys : array char of boolean
var piggy : int := Pic.FileNew ("F:/ICE3/Turing/Game/pics/piggy.BMP")
var background : int := Pic.FileNew ("F:/ICE3/Turing/Game/pics/background2.BMP")
var bulletBill : int := Pic.FileNew ("F:/ICE3/Turing/Game/pics/BulletBill.BMP")
var cloud : int := Pic.FileNew ("F:/ICE3/Turing/Game/pics/clouds.BMP")
var cloud2 : int := Pic.FileNew ("F:/ICE3/Turing/Game/pics/clouds.BMP")
var piggyX : int := 0
var piggyY : int := 0
var backgroundX : int := 0
var backgroundY : int := 0
var bulletBillX : int := 550
var bulletBillY : int := 10
var cloudX : int := 300
var cloudY : int := 250
var cloud2X : int := 150
var cloud2Y : int := 100
setscreen ("offscreenonly")


%intructions%
locatexy (230, 250)
put "Press Enter To Start Playing"

locatexy (160, 200)
put "To Control The Character Use The Arrow Keys"

locatexy (170, 180)
put "To Move Out Of The Way Of The Bullet Bill"

View.Update

Input.Pause
cls



loop



Input.KeyDown (keys)



% Character Blue Meanie and movements

%Move Character Right Across The Screen
if keys (KEY_RIGHT_ARROW) then

Pic.Draw (piggy, piggyX, piggyY, picMerge)
if piggyX >= maxx then
piggyX := -20
end if
piggyX := (piggyX + 2)

end if

%Move Character Left Across The Screen
if keys (KEY_LEFT_ARROW) then

Pic.Draw (piggy, piggyX, piggyY, picMerge)
if piggyX <= -100 then
piggyX := maxx + 20
end if
piggyX := (piggyX - 2)

end if

%Move Character Up The Screen
if keys (KEY_UP_ARROW) then

Pic.Draw (piggy, piggyX, piggyY, picMerge)
if piggyY >= maxy then
piggyY := -20
end if
piggyY := (piggyY + 2)

end if

% Move Character Down The Screen
if keys (KEY_DOWN_ARROW) then

Pic.Draw (piggy, piggyX, piggyY, picMerge)
if piggyY <= -100 then
piggyY := maxx +20
end if
piggyY := (piggyY - 2)

end if


% Move Bullets %

Pic.Draw (bulletBill, bulletBillX, bulletBillY, picMerge)

bulletBillX := (bulletBillX - 12)



if bulletBillX <= -100 then

bulletBillX := maxx + 20

end if


% Cloud Movement %

% Cloud One %
Pic.Draw (cloud, cloudX, cloudY, picMerge)

cloudX := (cloudX - 5)

if cloudX <= -100 then

cloudX := maxx + 20

end if

% Cloud Two %
Pic.Draw (cloud2, cloud2X, cloud2Y, picMerge)

cloud2X := (cloud2X - 5)



if cloud2X <= -100 then

cloud2X := maxx + 20

end if

%Draw Background And Characters %
Pic.Draw (background, backgroundX, backgroundY, picMerge)
Pic.Draw (bulletBill, bulletBillX, bulletBillY, picMerge)
Pic.Draw (piggy, piggyX, piggyY, picMerge)
Pic.Draw (cloud, cloudX, cloudY, picMerge)
Pic.Draw (cloud2, cloud2X, cloud2Y, picMerge)
View.Update
end loop



what i need help with is making the bullet move accros the screen randomly, and also i need to have the game end when the bullet hits the character any help would be awsome, because this is a school project due very soon thanks.
Sponsor
Sponsor
Sponsor
sponsor
Silent Avenger




PostPosted: Wed Dec 12, 2007 8:39 pm   Post subject: Re: help with collision detection and making the bullet move randomly

If you mean making the bullet start in a random location on one side of the screen you can use a randomly generated number between 0 and 1 multiplied by the height of your screen and have the bullet start at that location. As for the program ending when the player gets hit you'll need to use collision detection and end the program when it detects a hit. Useful source code can be found in the missile example game that comes with turing. Hope this helps.
shadox321




PostPosted: Wed Dec 12, 2007 8:53 pm   Post subject: Re: help with collision detection and making the bullet move randomly

thanks
shadox321




PostPosted: Wed Dec 12, 2007 9:15 pm   Post subject: Re: help with collision detection and making the bullet move randomly

can someone tell me what part of the missle program is the collision detection part lol, im really noobish at turing and also if possible can you help me edit it so it works in my game? thanks
Ultrahex




PostPosted: Wed Dec 12, 2007 11:50 pm   Post subject: Re: help with collision detection and making the bullet move randomly

Instead of taking others code!!! (which is cheating). Why not think of ways to do collision detection and implement it in the code for your program?
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  [ 5 Posts ]
Jump to:   


Style:  
Search: