Results 1 to 14 of 14
-
December 27th, 2004, 03:31 PM #1
Platformer Game - Collision not working for some reason
Okay.. I'm not really sure what happened to the other thread there. Some database error.
Anywho, what I said, was that I'm having a minor issue w/ a hittest i'm using in a script for a small platformer game I'm helping a friend with. The background is all one movieclip and I want the hero movie clip to recognize it as the ground. However, when the hero jumps, he commits suicide by jumping through the floor. I've looked at my code repeatedly and it looks fine, so I'm not really sure what the problem is, but I'm sure its something stupid.
I'm getting rather frustrated tho. If anyone wouldn't mind taking a moment to look at it and see if they can see what I'm missing, it would be much appreciated.
http://www.jlcreationsonline.com/syn...platformer.zip
The part of the code that is having issues is commented for easy finding.
Thanks again.
Last edited by jaelle; December 28th, 2004 at 03:48 PM.
-
December 27th, 2004, 05:49 PM #2301newb at work
postsoff topic
am sorry but that was funnyby the way why not post the code that way people can actually look at the code and maybe be able to pinpoint the problemhe commits suicide by jumping through the floormy sketches
Project||[GAME]
------------------
[Hero]-90%
[Enemies]-1%
[Weapons]-80%
[Items]-0%
[Levels]-5%
-
December 27th, 2004, 07:11 PM #3
Hi,
I can't view the game you made (it's not MX), but I did write two tutorials on how to create platform games; Just search the first page of the forum.
peace.: Let your Imagination Soar! :. -JoMan.
: Kirupa Nintendo Cult Member 31 :
-
December 27th, 2004, 11:06 PM #4
Yep joMan, I looked through your tutorials and incorporated them some, however, the problem I think I'm having is probably a a stupid error that happened from too much staring at code and now I'm blind to it
, I'm not really sure what else it can be.
Here is the swf: http://www.jlcreationsonline.com/syn...ame/final.html Notice how when you jump (up-arrow), he doesn't manage to ever hit the floor, but just keeps right on going.
Here is all code if that helps. My goal is to make the "It will be a miracle if this shows up" appear, which would also set the velocity to zero and stop its speedy decent. For some reason it never evaluates the hitTest to true, and i'm not sure why, considering it goes right over the top. I considered that since it is going in increments of 10, the x,y coordinate might never come in contact w/ the thin line that makes the ground. However, i made it go in increments of 1 and it didn't help. If I change the hittest statement to "_root.game_mc.limit_mc.hitTest(hero.mc)", I get the "It will be a miracle if this shows up" to appear, but he never jumps. Any suggestions would be most appreciated.
Code:import as.Enemy; import as.Hero; Enemies = []; hero = new as.Hero(game_mc.hero_mc); right = 1; left = -1; initializeEnemies(); initializeHero(); game_mc.onEnterFrame = function() { moveEnemies(); //****What is wrong here?****// if(!_root.game_mc.limit_mc.hitTest(hero.mc._x, hero.mc._y, true)) { hero.mc._y -= hero.getYvelocity(); //value for hero jump } else { trace("It will be a miracle if this shows up"); hero.Yvelocity = 0; } //**************************// hero.mc._x += hero.Xvelocity(); //value for horizontal velocity if (Key.isDown(Key.RIGHT)) { if(Key.isDown(Key.DOWN)) { duckmove(right); } else if(Key.isDown(Key.UP)) { jump(right); } else { run(right); } } else if (Key.isDown(Key.LEFT)) { if (Key.isDown(Key.DOWN)) { duckmove(left); } else if(Key.isDown(Key.UP)) { jump(left); } else { run(left); } } else if (Key.isDown(Key.DOWN)) { if (Key.isDown(Key.RIGHT)) { duckmove(right); } else if (Key.isDown(Key.LEFT)) { duckmove(left); } else { duck(); } } else if (Key.isDown(Key.UP)) { if (Key.isDown(Key.RIGHT)) { jump(right); } else if (key.isDown(Key.LEFT)) { jump(left); } else { jump(); } } else { stand(); } } function initializeEnemies() { Enemies.push(new as.Enemy(game_mc.enemy01_mc, 55, 345)); Enemies[0].mc.gotoAndStop("run_right"); } function initializeHero() { hero.mc.gotoAndStop("stand_right"); } function moveEnemies() { if (Enemies[0].mc._x >= Enemies[0].rightBoundary) { Enemies[0].mc.gotoAndStop("run_left"); Enemies[0].dir*=-1; } if (Enemies[0].mc._x <= Enemies[0].leftBoundary) { Enemies[0].mc.gotoAndStop("run_right"); Enemies[0].dir*=-1; } Enemies[0].mc._x += Enemies[0].speed * Enemies[0].dir; } function run(dir) { if (dir == right) { hero.mc.gotoAndStop("run_right"); } if (dir == left) { hero.mc.gotoAndStop("run_left"); } hero.mc._x+=hero.speed*dir; hero.dir = dir; } function duckmove(dir) { if (dir == right) { hero.mc.gotoAndStop("duckmove_right"); } if (dir == left) { hero.mc.gotoAndStop("duckmove_left"); } hero.mc._x +=hero.speed*dir; hero.dir = dir; } function duck() { if (hero.dir == right) { hero.mc.gotoAndStop("duck_right"); } if (hero.dir == left) { hero.mc.gotoAndStop("duck_left"); } } function jump(dir) { if (!hero.jump) { hero.Yvelocity = 10; } hero.Xvelocity = hero.speed*hero.dir; hero.jump = true; if (dir == right) { hero.mc.gotoAndStop("jump_right"); } if (dir == left) { hero.mc.gotoAndStop("jump_left"); } } function jump() { if (!hero.jump) { hero.Yvelocity = 20; } hero.jump = true; } function stand() { if (hero.dir == right) { hero.mc.gotoAndStop("stand_right"); } if (hero.dir == left) { hero.mc.gotoAndStop("stand_left"); } }
-
December 27th, 2004, 11:47 PM #5
Hmm, I'm not sure what the problem is either...
.: Let your Imagination Soar! :. -JoMan.
: Kirupa Nintendo Cult Member 31 :
-
December 28th, 2004, 10:31 AM #6102Registered User
postsI think that maybe the line is too thin, try it with a thicker line to see if that works...just a guess.
EDIT: Oops just re-read you post.Last edited by gaming monkey; December 28th, 2004 at 10:33 AM.
-
December 28th, 2004, 10:54 AM #7
I've got no clue what you did wrong, but from what I see you've made it way too complicated for a platform game...just look at Joman's tutes about platform games and don't get so tangled up with the code
-
December 28th, 2004, 11:28 AM #8
I'm a masochist programmer tho, I thrive off of making things complicated

But yea.. I probably will just have to write it over from scratch, since no one seems to know what the problem is.
-
December 28th, 2004, 11:40 AM #9Like you said though, it might be one of those small bugs that you can't find that drives you completely nuts
Originally Posted by jaelle
.
.: Let your Imagination Soar! :. -JoMan.
: Kirupa Nintendo Cult Member 31 :
-
December 28th, 2004, 11:46 AM #10
Well completely rewriting the code should fix that!
I'm going to go read through your tutorial a bit more closely now. Might as well go with the tried and tested way if trying to invent my own way fails.
-
December 28th, 2004, 11:53 AM #11But also, don't stop developing your own way in programming, It's a good thing to do, and it is a way that people will recognize you (next to the art you use).
Originally Posted by jaelle
peace.: Let your Imagination Soar! :. -JoMan.
: Kirupa Nintendo Cult Member 31 :
-
December 28th, 2004, 01:20 PM #12
that's true
Originally Posted by joMan
-
December 28th, 2004, 03:17 PM #13
Oh, no worries, I won't copy it word for word. But I might borrow the concepts.
-
December 28th, 2004, 10:52 PM #14That's a good thing to do
Originally Posted by jaelle
.
peace.: Let your Imagination Soar! :. -JoMan.
: Kirupa Nintendo Cult Member 31 :
Similar Threads
-
Game Help - Willing to Pay
By Sublim30 in forum Game/AI ProgrammingReplies: 3Last Post: April 11th, 2005, 04:17 PM -
Game Developers: UNITE!
By SeiferTim in forum Game/AI ProgrammingReplies: 162Last Post: January 19th, 2005, 02:04 PM -
Need Help[FMX] My actionscript game not working
By puthisorn in forum ActionScript 2 (and Earlier)Replies: 0Last Post: April 4th, 2004, 07:13 AM -
hitTest not working for plane collision
By ironikart in forum ActionScript 2 (and Earlier)Replies: 3Last Post: April 4th, 2003, 02:17 AM

Reply With Quote

Bookmarks