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 Shooting Collision!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
justin6996




PostPosted: Thu Dec 13, 2007 3:37 pm   Post subject: Need help With Shooting Collision!

ok....so im in grade 10 and am very far ahead of everyone and i made a little mario game and stuff like that....but now i made a game were u have a stick figure hold a gun. and when you hit "ctrl" he shoots a bullet......the code for that was


1) Pic.Draw (picright, x, y, picMerge) %%%% picright is my character facing right
2) Pic.Draw (bullet,(x+55)+i),y +70,picMerge)
3) View.Update
4) delay (20)
cls


ok if u dont get what im doing in line 2...the word bullet is the picture of the bullet i have declaered earlier... the (x+55+i) means that since the gun is on the right side of the picture....the bullet stars from the (x+55) part of my pictuer. and the i makes it go down the screen.

so then i have this also

Pic.Draw (crate,x2,y2,picMerge)

the crate is the picture that pops up randomly on the screen and that you can shoot.....what i wana know is how to make the collision code for the bullet and the crate.....i have tried things for HOURS!!! and cant figure it out....if u know how to help

PLEASE RESPOND!
or email to : zygora_52@hotmail.com
justin6996@gmail.com
Sponsor
Sponsor
Sponsor
sponsor
Euphoracle




PostPosted: Thu Dec 13, 2007 3:41 pm   Post subject: RE:Need help With Shooting Collision!

If you know the rectangular bounds of the crate and bullet, you can check if they intersect. There is a handy tutorial for this in the "Tutorial" section of the Turing forum (it's a sticky, you can't miss it :p).
justin6996




PostPosted: Fri Dec 14, 2007 11:22 am   Post subject: Re: Need help With Shooting Collision!

Okay i tried reading the guide that you recomended, but my problem is , i have the collision thing and the X co-ords of the bullet is the x co-ords of my person + (i) and I goes from 100 to 500, so that it moves across the screen, but when i do the collision...what happens is i make it so like....if the x co-ords of the bullet are greater then the crate i want to shoot , then the crate disaprear, but since the X co-ords is the X co-ords of my character + 50, the collision jsut doesnt work......could any1 help me on a new way to make the bullet go across the screen from my character? and get the intersection of the bullet + crate to work ?!
richcash




PostPosted: Fri Dec 14, 2007 1:47 pm   Post subject: Re: Need help With Shooting Collision!

I'm not too sure what's going on here without the code but I strongly suggest you don't make your bullet's position relative to your person's position. I would make a fresh variable equal to the person's x at the time of shooting and then add to that bullet's new x variable.

Then your collision check might be easier to implement.
justin6996




PostPosted: Fri Dec 14, 2007 3:16 pm   Post subject: Re: Need help With Shooting Collision!

okay i tried taht and it doesnt work.....heres my game, some1 please try to amke it so when the bullet hits the crate you gain a point!!! aka the collision!


FIRSTSHOOTERr.txt
 Description:
here is the code in Note pad, just copy and paste it into turing :)

Download
 Filename:  FIRSTSHOOTERr.txt
 Filesize:  1.7 KB
 Downloaded:  119 Time(s)

justin6996




PostPosted: Fri Dec 14, 2007 3:18 pm   Post subject: Re: Need help With Shooting Collision!

and heres the pictures to go along with it Very Happy


barrel.GIF
 Description:
 Filesize:  947 Bytes
 Viewed:  2105 Time(s)

barrel.GIF



righty.GIF
 Description:
 Filesize:  1.21 KB
 Viewed:  2106 Time(s)

righty.GIF



lefty.GIF
 Description:
 Filesize:  1.21 KB
 Viewed:  2106 Time(s)

lefty.GIF



BULLET.GIF
 Description:
 Filesize:  852 Bytes
 Viewed:  2107 Time(s)

BULLET.GIF



righty.GIF
 Description:
 Filesize:  1.21 KB
 Viewed:  2106 Time(s)

righty.GIF


Nick




PostPosted: Fri Dec 14, 2007 3:30 pm   Post subject: RE:Need help With Shooting Collision!

hint of advice if you had two sperate pics for the body and arms and then used Pic.Rotate you could have the arms move depending on where he is shooting (so if he shoots down it looks like he shoots down)
justin6996




PostPosted: Fri Dec 14, 2007 3:48 pm   Post subject: Re: Need help With Shooting Collision!

eh, idc about taht stuff atm, i just wana make it so when the bullet hits something you get points or something
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: