Help Wanted

2d platforms – skynes

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
I understand it'd be pretty difficult to help me with a problem with me just describing it.

http://skynes.tripod.com/TheWizard.zip

There's a link to a zip file containing my XNA project and all images.

The Project so far is a mix of a couple of tutorials I found online (2d wizard and a tile engine) along with sprites I found online. I haven't made any of my own sprites yet cause I don't see the point until I have everything working, but I will be using all my own original sprites when it works.

Anyway.

so far it's a wizard who can jump and shoot fireballs. An enemy (currently commented out) walks across the screen, firballs dont do anything yet, but touching the enemy costs you a life.

My problem is with the platforms. I can jump onto the platforms ok, but if you jump while on the platforms you end up hanging in mid-air. I've tried incorporating a gravity effect, so when you move off the platforms you fall, but I haven't had any luck with it.

samw3

Member

Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
Love to help, but tripod is not letting me download your file. Maybe sign up for xdrive and sharing it from there.

------------------
Sam Washburn

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
Durrrr... me skynes... me do daft fings... durrrr...

Tripod doesnt allow remote access...

try http://skynes.tripod.com on its own.

samw3

Member

Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
I can't find the bug just by looking at the code. When I try to run your exe it bombs.. i might need to update directx.. anyhoo.. I noticed that your jump routine has an up-and-down action to it. Perhaps change the jumping to end just when the wizard crests the top of the jump then switch to the fall routine. It might simplify the code for the gravity and reveal this bug you have.

------------------
Sam Washburn

[This message has been edited by samw3 (edited February 22, 2007).]

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
My bug was in collision detection... I was checking if the Wizard is on the ground and if he is, to set his position to 300, so that gravity won't make him fall forever...

However I botched the check for 'on the ground' so even when he jumped, he was STILL on the ground for the purposes of the check... SO He never jumped.

Anyone know anything about how to get platforms to work?

My platform code:

public void OnPlatform()
{
foreach (KeyValuePair<string, Sprite.Sprite> aPlatform in mPlatforms)
{

//check if Wizard is on platform Y
if ((mWizard.Position.Y + mWizard.Height) <= aPlatform.Value.Position.Y)
/*(mWizard.Position.Y + mWizard.Height) <= (aPlatform.Value.Position.Y + aPlatform.Value.TextureHeight))*/
{

//check if wizard is on platform X
if ((mWizard.Position.X + mWizard.Width) >= aPlatform.Value.Position.X &&
(mWizard.Position.X) <= (aPlatform.Value.Position.X + aPlatform.Value.TextureWidth))
{
mWizard.Position = new Vector2(mWizard.Position.X, aPlatform.Value.Position.Y - mWizard.Height + 10);
mOnPlatform = true;

}


}//If the Wizard is on a platform

if (mWizard.Position.Y == 300)
{
mOnPlatform = true;
}

}
}