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

Username:   Password: 
 RegisterRegister   
 aRcaDe Fighters ~ Perfecting Collision Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
(-.-)>YoGi~BeHR<(-.




PostPosted: Sun Dec 03, 2006 6:30 pm   Post subject: aRcaDe Fighters ~ Perfecting Collision Help

Warm greetings to everyone at CompSci, and thanks ahead for anybody who posts; now lets get to the core.

Problem 1:
I want the character to fall off the platform once he moves off the edge... how to accomplish this?

Problem 2:
However, character passes right through the platform and only detects it (with whatdotcolour) once he has already jumped on top of it.

Hypothetical solution:
At the end of my program (code below) creates a rectangle that has an exact fit to the character. I've attempted to do collision this way; having the rectangle do collision with the other rectangles and then the image only interpreting that. However, this resulted in unprecedented failures. If someone could clarify and suggest if this method > whatdotcolour.

Quote:

Draw.FillBox ((SpiderManX div 1) - 1, (SpiderManY div 1), (SpiderManX div 1) + 58, (SpiderManY div 1) + 96, 44)


You need my zip for the images as well if you wish to fully understand what my two problems are:

CODE:

Quote:

%[Character 1]
var SpiderMan1, SpiderMan2 : int
%[Starting Positions]
var SpiderManX : real := 0
var SpiderManY : real := 80
var win : real := 45
var SpiderMan_VX, SpiderMan_VY := 0.0

%[Movement] - [Collisions]
const gravity := 0.1
var jumpcount : int := 0
var Boolean, Jumping : boolean := false
var Chars : array char of boolean

%[Declare File Import]
SpiderMan1 := Pic.FileNew ("SpiderManLeft.bmp")
SpiderMan2 := Pic.FileNew ("SpiderManRight.bmp")

win := Window.Open ("position:center;center,graphics:800;600")
View.Set ("offscreenonly")

%[Ground]
loop
View.Update
Input.KeyDown (Chars)
cls
Draw.FillBox (0, 0, maxx, 43, 23)
%Platform
Draw.FillBox (maxx div 2 - 50, 80, maxx div 2 + 50, 90, 23)
%Platform
Draw.FillBox (0, 0, 100, 80, 23)

%[Movement Code]
if Chars (KEY_RIGHT_ARROW) and SpiderManX < 745 then
SpiderManX := SpiderManX + 1
Boolean := false
elsif Chars (KEY_LEFT_ARROW) and SpiderManX > 0 then
SpiderManX := SpiderManX - 1
Boolean := true
elsif Chars (KEY_DOWN_ARROW) and SpiderManX > 0 then
SpiderManX := SpiderManX - 1
Boolean := false
end if

%[Jump Sequence]
if Chars (KEY_UP_ARROW) and not Jumping then
Jumping := true
SpiderMan_VY := 5
end if

if Jumping then
SpiderManY += SpiderMan_VY
SpiderMan_VY -= gravity

%[Collision]=>[Destructable Environments]
if whatdotcolour (SpiderManX div 1, SpiderManY div 1) = 23 then
Jumping := false
end if
end if

%Box surrounding character for potential collision detection?
Draw.FillBox ((SpiderManX div 1) - 1, (SpiderManY div 1), (SpiderManX div 1) + 58, (SpiderManY div 1) + 96, 44)

if Boolean = true then
Pic.Draw (SpiderMan1, round (SpiderManX), round (SpiderManY), picCopy)
else
Pic.Draw (SpiderMan2, round (SpiderManX), round (SpiderManY), picCopy)
end if
delay (5)
end loop

Sponsor
Sponsor
Sponsor
sponsor
(-.-)>YoGi~BeHR<(-.




PostPosted: Sun Dec 03, 2006 6:33 pm   Post subject: (No subject)

The zip is below:

http://files.filefront.com//;6293171;;/

I'm starting to think if the problem is not related to using booleans.... for the jumping sequences.
Hackmaster




PostPosted: Sat Dec 09, 2006 7:08 pm   Post subject: (No subject)

I would love to help, and I have some experience in the feild... but...

I need those images in ZIP form!! not RAR! and, please... it's only 15 kb... just post it on this site as opposed to making the people have to go to bloody filefront. ok? that would be great.

The box system works. I have tryed it. also.. for the x, y declarations, you don't need reals. they only take ints anyways. and, if you are really finickity... reals take up more space in memory anyhow.

anyways, ya.. get those .zips up quick quick! Very Happy thanks...

also, on a side note... from your username, I thought you were gonna be one of those stupid "PwNXoR HaX3R5", but you are one of the most coherent posters i've seen in a while! just an observation!
(-.-)>YoGiBeHR<(-.-




PostPosted: Mon Dec 11, 2006 7:31 pm   Post subject: (No subject)

Thank you HackMaster, my name is just an "adapted" form of a cartoon show from childhood. I now regret not having checked this post sooner, as you may not be back.

Anyways, I've managed to fix the main problem, getting the character to fall off the platform as he moves; although I am not entierly sure if it is the most optimized method. However, he still passes through the terrain, which is not as big an issue, but resolving it would be fine. If you have a method you wish to share, or point me in the right direction where I could do that (preferably in the Procedure Collision) or (Key input).

Below is a ZIP file of the program at the moment, as well as the bonus characters, which will be implemented later on, so stay tuned please.



Arcade Fighter.zip
 Description:
ZIP file of the program at the moment

Download
 Filename:  Arcade Fighter.zip
 Filesize:  86.98 KB
 Downloaded:  78 Time(s)

(-.-)>YoGiBeHR<(-.-




PostPosted: Mon Dec 11, 2006 7:39 pm   Post subject: (No subject)

Keyboard Input
------------------

Up, Left, Right, Down Keys
Up + Left || Up + Right = Move character in mid air
Up + Left + Ctrl || Up + Right + Ctrl = Super Jump
Mouse left click - reposition character



A side Note:
If you wish to test my program, be aware that it may run differently on your computer due to your hardware. In the first procedure you can change the Delay (which will affect performance, at least visually) and this delay will better suite it to your computer.

PS: This is an open source project Smile
Hackmaster




PostPosted: Mon Dec 11, 2006 8:29 pm   Post subject: (No subject)

Don't you worry yourself... I watch my posts like a hawk...Smile

your program. ok. so let's start with problems to fix. I see that if you don't jump onto the platform in the middle, you walk through it. otherwise, I didn't find to many bugs. Graphically, though, you really need to get rid of that box around spidey, which is easily done in paint... unless it's a jpg.. if you can find a gif, that's great!

when it comes to open source, I love the stuff. I participate (altough not all that activley) in sourceforge. net, and places like that. However...I was wondering.. what is your programming experience? I would Love some help on this game I'm making, but it would require knowledge of Objects, and classes. and all that good stuff. It could be a trade off, if you like. But, I'm gonna hazard a guess and say because you are posting for help with basic collision detection, you don't really know enough about that stuff to be all that helpful... am I right?
(-.-)>YoGiBeHR<(-.-




PostPosted: Mon Dec 11, 2006 9:03 pm   Post subject: (No subject)

Yeah , your entirely right, open source was a little side joke lol. The box around spidey, you are reffering to the black box around him? Thats no problem to get rid of, it will take 20 seconds in photoshop.

The problem with it is that he walks through the platforms, I'm going to venture a guess here that whatdotcolor collision has to be done for every left, or right key press, am I right?
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  [ 7 Posts ]
Jump to:   


Style:  
Search: