Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-23-2010, 07:49 PM   #1
GRStudios
Registered User
 
Join Date: Mar 2007
Posts: 6
Question [AS2] help with programming a platform game

Im designing my platform-adventure game, yet i have problems with the actionscript. I found once a platform game 'engine', buy it has only functions for jump, walk, gravity issue, hitTest with the ground and campera panning automaticly.
I ask you guys for help, mostly for finding sources which can upgrade my game, and in particular a problem which i try to solve as a noob with AS: My character's 'weapon' is an umbrella which can also be used as a parachute f some sort. I would like that if the character jumps and you press, lets say the SPACE key, then it will go to the desired frame, yet stay in the 'parachute' frame even if you move to the sides (and not showing walking animation).
There is my code: (as i got from the tutorial)
ActionScript Code:
// onClipEvent (load) {     var grav:Number = 0;     // gravity     var speed:Number = 10;     // how fast you walk     var jumpHeight:Number = 13;     // how high you jump     var slow:Number = .7;     // sets water falling speed     var slowspd:Number = speed/1.5;     // sets water walking speed     var setspeed:Number = speed;     var scale:Number = _xscale;     var ex:Number = 5;     // makes hitTests better, change for a closer hitTest (warning, more buggy if small, less real if further)     this.gotoAndStop(1); } onClipEvent (enterFrame) {     grav++;     _y += grav;     while (_root.ground.hitTest(_x, _y, true)) {         _y--;         grav = 0;     }     if (_root.water.hitTest(_x, _y, true)) {         if (grav>0) {             grav *= slow;         }         speed = slowspd;     } else {         speed = setspeed;     }     if (Key.isDown(68)) {         _x += speed;         _xscale = scale;         if (_root.ground.hitTest(_x, _y+3, true)) {             this.gotoAndStop(2);         } else {             this.gotoAndStop(3);         }     } else if (Key.isDown(65)) {         _x -= speed;         _xscale = -scale;         if (_root.ground.hitTest(_x, _y+3, true)) {             this.gotoAndStop(2);         } else {             this.gotoAndStop(3);         }     } else {         if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {             this.gotoAndStop(1);         }     }     if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {         grav = -jumpHeight;         _y -= 4;         this.gotoAndStop(3);     }     if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {         _x -= speed;     }     if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {         _x += speed;     }     if (_root.ground.hitTest(_x, _y-_height-15, true)) {         grav = 1;     } }

Last edited by CyanBlue; 02-23-2010 at 07:59 PM. Reason: AS Tag applied...
GRStudios 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 09:17 PM.

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