Forum > Help with a 2d tile / collision with sprite

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

September 14, 2008 | Unregistered CommenterShawn

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.

September 14, 2008 | Unregistered CommenterShawn

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...

September 14, 2008 | Unregistered CommenterJDog

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 :-(

September 15, 2008 | Unregistered CommenterShawn

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...

September 16, 2008 | Unregistered CommenterJDog

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?

October 12, 2008 | Unregistered CommenterShawn

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.

September 28, 2009 | Unregistered CommenterAnon

When you get ready to sell your Alabama land do you sell it yourself or should you use a licensed Realtor. I will outline zara usa several reasons you should consider using a Real Estate professional to help you sell your Alabama Real Estate.
If you have Land for sale in Alabama and you are ready to put it up for sale are you planning on trying to market your land your self or have you thought about a Real Estate Broker. I will go over a few pro and cons for both and then you can chose for yourself. Let’s discuss to cons of a Realtor first, the commission is going to be the thing that will concern most people first and yes this can add up to be thousands especially on a large transaction. One more thing that concerns the average person is you also have to sign a listing agreement which is in essence a contract that lets the Realtor control the marketing of your property for either six months or some even a year. These are the main draw backs to listing your Alabama land for sale with a Realtor.
I will try and zara usa online go into great detail on the pros because as I zara usa have sold hundreds of land tracts and houses in my career in Real Estate I have also sold many properties through a good Realtor and believe that even with a lot of experience you should at least look very hard at listing with an aggressive qualified Real Estate Broker and here are some reasons why. One of my biggest pros for a Realtor is overall marketing exposure, an individual even in this day of internet land listing websites just can’t get the overall exposure that your property will need to sell. Most Realtors know the best websites and are members and will get your land listed on them for you. Even though being on all the right sites is much cheaper than print ads you still need to know how to word your listing and know the top sites to post on. Another good reason to use a Real Estate Broker is the client base they will have and the old hip pocket buyer and by hip pocket buyer I mean someone they have been talking to about certain types of properties and they know they will by if they find it.
Now I will go over the number one thing in today’s market that an individual just can’t get done and that is financing the land after the sale is contracted. If you don’t think this is worth a commission just get your land under contract and zara clothing try to find the buyer the money. Unless he has an 830 credit score and over twenty to thirty percent down (these buyers are hard to find) it isn’t going to happen...this is where you will lose most sales.
I am shooting this as straight as I can with you. Unless you have experience selling Alabama Real Estate yourself and I mean a good bit of it I would suggest using a licensed Real Estate Broker to sell your property for you.

April 3, 2013 | Unregistered Commenterzara usa

http://www.fzdby.com
fzdby
[url=http://www.fzdby.com]fzdby[/url]

May 30, 2014 | Unregistered Commenterchenchuanwe