Forum > Help with a 2d tile / collision with sprite
Guess I could also mention that I really hate the "JUMP" routine also. It looks really bad, any thoughts on how to improve the "realisticness" of that would help me out also.
Edit: I re-read the above. Have your collision Tile to player collision code so it can be accessed from any part of your code...and have it so the same collision affects are called when walking just as they are when jumping... You'll work it out, either way, read my ramblings beneath...
Well I'd call a jump variable set it to false, if jumping is false have all the regular coding for jump in this area, if jumping is activated to true however on the press of the spacebar have a seperate section of code which covers all the collision if its true as opposed to false. I use the technique of circumstantial collions, I found it the best way to make progress...until I leveled up !
float jump = false;
if(jump == false)
{
//What would happen normally, update loop and all
}
if(jump == true)
{
//When the player jumps, do this !
}
TBH its just the ramblings of a rather tired person here so you're choice...
I actually went back and did it all over from scratch, this time using BoundingBox....is still isnt working right...
Maybe I fail as a programmer :-(
Bounding Box ? Oh, for bounding box collisions, hate those.
Well, whenever I do Tile Based games in flash, not scrollers, I create my array filled with tiles.
Then load that array into an empty image file then check the collision with the empty collision file, it speeds up the code as its all solid where theres tiles and empty when there's non and you only check collision for one object and not for every object onscreen at once.
Maybe this theory can be translated into C#, I should give it a go, if only I knew how to do an array...
I went back and redid my tile collision checks and just a free roaming sprite. I am now using my sprites upper left, lower left, upper right, and lower right corners, minus a few pixels to determine where the next move may take the sprite. As long as the cell is a "-1" value, the sprite can move to that cell.
This seems to be working fine except for taking into account the sprite "speed." I am moving the sprite based on values from the left thumbstick of the controller, and multiplying that by the speed of the sprite. Currently, I have a sprite speed set for 3 pixels. The problem I am now seeing, the sprite will approach an object, stop a few pixels short, because next move indicates a collision, and the subsequent update will allow the further move the couple pixels the sprite is short of the object.
It is making for a jerk effect as the collision happens. I guess my next question is, how to account for the fact that the "speed" variable may place the sprite into a collision, but the object is still say 1 or 2 pixels away (since I am using 3 for sprite speed)?
Any suggestions?
Question, why would you use "float jump = false"? A float is a like a double but more accurate, e.g. in XNA a float is designated like so: float myHeight = 182.5f; It is always followed by a "f" to show that it's a float, I think what you are looking for is "Boolean" or "bool" for short.
ugg classic zipper boots
ugg 5818 roxy boots
ugg tall leather boots
ugg stripe cable knit boots
ugg roxy tall 5818
ugg short boots 5808
ugg sundance ii
Wholesale Green Bay Packers jerseys
ugg tall chestnut
ugg tall boots chocolate
ugg classic boot pink
ugg classic boot sand
UGG boots Highkoo
KidS Bailey Button UGG boots



Hello all,
Not sure if anyone wants to try and help me figure this out, but no harm in asking. With the help of Rob's book and one other website, I am on my towards doing a 2d side scroller kind of game.
I have stripped this code down as best I can, although the Player.cs and CollisionCheck.cs files are really a mess at this point. Here is the controls:
A - move left
D - move right
Space Bar - Jump
Here is the issue:
Moving left and right without jumping detects collisions between tiles and the player sprite. However, adding a jump causes the player sprite to be able to move into cells with tiles if he moves left and right while jumping. As I said the code in the two files I think are the source of the issue are a bit of a mess right now, and I apologize for that, been working on figuring out the problem for a while now with no success. :-(
Here is a link to the project if you would like to help me figure it out!
LINK