Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-14-2004, 08:20 PM   #1
Amaster
Registered User
 
Join Date: Sep 2004
Posts: 3
Default [AS2] Problems with platform game (jumping and collision issues)

I am working on a simple sidescrolling "game" and am experiencing the following problems:

1) If the player lands while holding the jump button (space), he immediately jumps again. I've tried solving this on my own but I only introduced more problems :P

2) Sometimes the player sinks patially into the ground upon landing. I cant figure out why this happens exactly. Could it be a side effect of problem #1?

Here is my code (I have attached the fla as well):
ActionScript Code:
velocity = 0; gravity = 0.7; player = function () { }; player.prototype = new MovieClip(); Object.registerClass("block", player); player.prototype.onEnterFrame = function() {     walking = ground.hitTest(this._x, this._y, true);     if ((Key.isDown(Key.SPACE) && walking) || !walking) {         this._y -= velocity;         velocity -= gravity;     }     if (walking) {         velocity = 10;     }     if (Key.isDown(Key.RIGHT)) {         this._x += 5;     }     if (Key.isDown(Key.LEFT)) {         this._x -= 5;     } }; _root.attachMovie("block", "player1", 1);

Also, this is one of my first attempts at object oriented programming. So if I'm doing something wrong in that area, please let me know.

Thanks for any and all help.
Attached Files
File Type: zip gravity.zip (5.2 KB, 268 views)
Amaster is offline   Reply With Quote
Old 09-14-2004, 08:54 PM   #2
James_H1023
Jam
 
James_H1023's Avatar
 
Join Date: Jul 2004
Location: UK
Posts: 53
Send a message via MSN to James_H1023
Default

i don't understand why don't you want it jump straight away does it bug or something?

i look at zip and see
James_H1023 is offline   Reply With Quote
Old 09-14-2004, 08:56 PM   #3
Amaster
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

Well, I would prefer if the player were forced to release and then press the spacebar again in order to perform a second jump, as opposed to simply holding down the key. Also I suspect it may be causing the second problem I listed.
Amaster is offline   Reply With Quote
Old 09-14-2004, 08:59 PM   #4
James_H1023
Jam
 
James_H1023's Avatar
 
Join Date: Jul 2004
Location: UK
Posts: 53
Send a message via MSN to James_H1023
Default

right ok me looking at your fla
James_H1023 is offline   Reply With Quote
Old 09-14-2004, 09:11 PM   #5
James_H1023
Jam
 
James_H1023's Avatar
 
Join Date: Jul 2004
Location: UK
Posts: 53
Send a message via MSN to James_H1023
Default

ok i have an idea, to stop the space bar thing repeating maybe put a variable in the space bar so when the space bar goes down it is 1 and when the space bar comes up it goes 0.

and the space bar code only runs when the var = 0;

duno how to check if space bar is up maybe a listener
James_H1023 is offline   Reply With Quote
Old 09-14-2004, 09:21 PM   #6
Amaster
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

I tried creating a listener object originally, and it did function properly (I traced it to make sure I set it up right), but I wasnt able to implement it in a useful manner. I just ended up with more weird bugs. Maybe I did it wrong.

Thanks for looking at the file though.
Amaster is offline   Reply With Quote
Old 09-14-2004, 09:26 PM   #7
James_H1023
Jam
 
James_H1023's Avatar
 
Join Date: Jul 2004
Location: UK
Posts: 53
Send a message via MSN to James_H1023
Default

yea i can only think that a listener listening for when it is up would do, can't think of another way although there probs is.

np
James_H1023 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.