|
|||||||
| Forum Home | Register | Members List | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 | ||||||||
|
Junior Member
|
I know I'm a little late to be trying this, but I've been trying to think of things I can work on for a while. I'm working offshore right now, so when I'm not working I can spend my spare time programming at this, and hopefully get it done before the deadline.
My only question is, can I use SDL/C++? |
||||||||
|
|
|
|
|
#22 | ||||||||
|
Senior Member
Location: London |
Yes providing it will run with little effort on the judges machines.
|
||||||||
|
|
|
|
|
#23 | ||||||||
|
Member
Location: N. America |
Rant time
![]() Collision resolution is the one this time! I have been scratching my head for quite some time now to make this work, but, gah!! So, I am trying to get my character(which is no more than a square as of now) to move in the world. So, when there is a obstacle in front of him, he should not be able to move and when he jumps and lands on a height-tile, he should stop there...you get the idea! Well, implementing it is not easy as it sounds (or maybe its just me over-engineering). So, here is what I did.. Depending on: Code:
(OriginX + velocity.X - CellCenterX)
After I get that list, I see if all the squares are walkable. If they are, the character moves, else he doesn't. Now, this works fine for the X axis, but when I get into the Y axis, things go for a toss I dont know whats messing up..my logic..my approach or what..please suggest me how should I solve it. I have done lots of headbanging...aaaa!And ya, ignore the insanity @ display..radiation from my monitor with no output often leads me to this! PS: Hit D to toggle debug info and P to pause/unpause Last edited by brainydexter : 01-13-2009 at 11:04 PM. |
||||||||
|
|
|
|
|
#24 | ||||||||
|
Senior Member
Location: London |
Ah yes, I remember the days of battling with platform game collision detection. A more accurate name for what you need is "Collision Detection and Response", which means it's not enough to simply detect collision & forbid movement when it occurs, you also need to compensate by having the player 'bounce back' or slide along the surface so that they don't get stuck in a state of perpetual collision, and can never escape.
I've writen a method for you that you may find useful: Code:
private float FindGroundLevel(Vector2 pos)
{
Point checkPoint = Point.Zero;
float lastClearPoint = pos.Y;
checkPoint.X = (int)(pos.X) / Constants.TileWidth;
while (pos.Y < Constants.WindowHeight)
{
checkPoint.Y = (int)(pos.Y + objectSprite.Height) / Constants.TileHeight;
if (world.mapValueAt(checkPoint.X, checkPoint.Y) != 6 && world.mapValueAt(checkPoint.X, checkPoint.Y) != 0) // Non-empty space detected
break;
lastClearPoint = pos.Y;
pos.Y++;
}
return lastClearPoint;
}
Code:
/*
* Old collision code
*
if (velocity.Y < 0)
velocity.Y += 0.1f;
else if (velocity.Y > 0)
{
velocity.Y += 0.1f;
}
*/
float groundPos = findGroundLevel(new Vector2(position.X + (objectSprite.Width / 2), position.Y - (objectSprite.Height/2)));
if (position.Y < groundPos)
velocity.Y += 0.1f;
else if (position.Y > groundPos)
{
velocity.Y = 0.0f;
position.Y = groundPos;
}
|
||||||||
|
|
|
|
|
#25 | |||||||||
|
Member
Location: N. America |
yaay! Thanks claxon, once again. I really appreciate your help and guess what, it works..yaaay ![]() But, I have a question for you.. I dont understand how Findground(..) works between the range.. (player.posY - height/2) to (player.posY + height/2). Also, why do we choose to do this.. Quote:
.Anyways, next stop, I'm thinking to define my level. Thanks a ton ![]() Last edited by brainydexter : 01-14-2009 at 09:02 PM. |
|||||||||
|
|
|
|
|
#26 | ||||||||
|
Senior Member
Location: London |
FindGroundLevel() is basically the code from one of your existing methods to test if it is a floor tile put into a loop. You pass it a world position and it will check to see if that position is a solid platform. If it is, it will return the position you passed (though the ground level may actually be higher, because it doesn't trace upwards), if however it is an empty tile, the loop will increment the Y position (move one pixel down) and run the check again. Basically it will check every pixel until it hits a platform, then it will return the last empty pixel.
When we call float groundPos = findGroundLevel(new Vector2(position.X + (objectSprite.Width / 2), position.Y - (objectSprite.Height/2))); it starts checking from the Top-Center point of your player sprite and then scans all the way down beyond the sprite's feet. I did it here rather than start at the sprite's feet because if the sprite happened to be just 1 pixel too far down, it would instantly collide with the floor, and would stop moving. Where you trace from is really up to you though. |
||||||||
|
|
|
|
|
#27 | ||||||||
|
Member
Location: Tuckahoe, NY |
I am working on this using DirectX and C++ and my progress is quite slow. I am basically learning as I go on this one, and as of now I have only have a ship that can move and fire bullets terribly. I am trying to establish a rate of fire as of now because the bullets collide and it doesn't look very nice. I am currently at work, but if you guys want me to zip up the code, I can do that from home tonight. I don't think I will be able to finish the game by the deadline to perfection, but might just enter it for criticism and complete it later on. I just need some direction on what to do next once I get collision detection down.
|
||||||||
|
|
|
|
|
#28 | ||||||||
|
Member
|
If you have a functional ship that can move back and forth, and shoot projectiles than thats a pretty solid start.
I'd work on whatever enemy mechanic you'd want to focus on in the game. How they spawn in the world... How they move... some pathing, or something similar along those lines |
||||||||
|
|
|
|
|
#29 | ||||||||
|
Junior Member
Location: Seattle WA |
is the deadline on Sunday the 25th? or Tuesday the 27th?
__________________
my gamedev blog |
||||||||
|
|
|
|
|
#30 | ||||||||
|
Senior Member
Location: London |
Whoops! I was obviously looking at January 2008 instead of 2009! I've changed it to Sunday 25th January. Sorry for the confusion!
|
||||||||
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 12:14 PM.




















yaay! Thanks claxon, once again. I really appreciate your help and guess what, it works..yaaay 


Linear Mode

