PDA

View Full Version : Help with platform game



tcooley2003
July 14th, 2005, 03:03 AM
Hi all,

I am new to this board but have been looking over the tutorials and boards for years now. I only know some limited actionscript. I have an assignment in school to make a scrolling platform game and I only have 6 weeks to do it in. I only need 1 level for class, but would like to make multiple ones for my own endeavors. In trying to make a game, I have ran into many problems but have overcame some of them, but now am kinda stuck and could use some help from the experts out there. I realize my coding is sloppy and am working to clean it up. I would appreciate any suggestions of how to do things to where they will work better/more reliable. Some problems I am having are not limited to but include:

- After jumping, the "hero" does not always stop at the same point on the ground when landing.

- I have tried many ways to do platforms and have had no luck. Detecting when he lands on them versus is just pushed up against a block or platform and cannot go any further.

- Scrolling the platforms in a full stage scene.

- I have buttons to stop and start scrolling, if the character is to the right of the scrollpoint and you turn scrolling back on, it just jumps to the point where he is in the middle instead of scrolling smoothly. The background also does not always align properly....especially when reaching the end of the movieclip that scrolls it.

There is probably more, but that is all I can think of right now. The graphics suck right now and the background is just a wallpaper I have for my desktop until the real graphics are ready.

The swf is here:
http://home.ripway.com/2005-5/315831/action10.swf

FLA to mess with is here:
http://home.ripway.com/2005-5/315831/action10.fla

Coding I have so far:

in first frame to set up variables:

_root.lockscroll = 1; //1 = scrolling on, 2 = scrolling off
_root.howfast = 10; //Walkspeed
_root.walking = 1; //Toggle - 1 = standing, 2 = right facing walk, 3 = left facing walk
_root.jump = 1; //1 = on ground, 2 = in a jump going up, 3 = falling
_root.jumpH = 130; //How high you jump
_root.midjump = 80; //How high the midjump is - minimum jump
_root.jumpS = 15; //How fast you jump
_root.upheld = 1; //Determines if UP key is being held down - 1 = no, 2 = yes
_root.jumpvalue = 0; //Temp spot to hold jump calculations
_root.jumpvalue2 = 0; //Another temp jump caculation spot

on the hero movieclip:

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_root.facing = 2;
if (this._x>50) {
this._x -= _root.howfast;
if (_root.jump == 1) {
if (_root.walking == 1 or _root.walking == 2) {
_root.walking = 3;
_root.hero.gotoAndPlay("left");
} else if (_root.walking == 3) {
_root.hero.nextFrame();
}
}
} else {
_root.hero.gotoAndStop(3);
}
} else if (Key.isDown(Key.RIGHT)) {
_root.facing = 1;
if (_root.lockscroll == 1) {
if (this._x<300) {
if (this._x>250) {
this._x -= _root.howfast;
_root.back.nextFrame();
_root.back2.nextFrame();
_root.back2.nextFrame();
_root.back3.nextFrame();
_root.back3.nextFrame();
_root.back3.nextFrame();
}
this._x += _root.howfast;
if (_root.jump == 1) {
if (_root.walking == 1 or _root.walking == 3) {
_root.walking = 2;
_root.hero.gotoAndPlay("right");
} else if (_root.walking == 2) {
_root.hero.nextFrame();
}
}
}
} else if (_root.lockscroll == 2) {
if (this._x<550) {
this._x += _root.howfast;
if (_root.jump == 1) {
if (_root.walking == 1 or _root.walking == 3) {
_root.walking = 2;
_root.hero.gotoAndPlay("right");
} else if (_root.walking == 2) {
_root.hero.nextFrame();
}
}
} else {
_root.hero.gotoAndStop(1);
}
}
} else {
if (_root.facing == 1) {
_root.walking = 1;
if (_root.jump == 1) {
_root.hero.gotoAndStop(1);
}
} else if (_root.facing == 2) {
_root.walking = 1;
if (_root.jump == 1) {
_root.hero.gotoAndStop(3);
}
}
}
}
onClipEvent (enterFrame) {
_root.upheld = 1;
if (Key.isDown(Key.UP)) {
_root.upheld = 2;
if (_root.jump == 1) {
_root.jump = 2;
_root.jumpvalue = _root.hero._y-_root.jumpH;
_root.jumpvalue2 = _root.hero._y-_root.midjump;
_root.gravity = _root.jumpS
}
}
if (_root.jump == 2) {
if (_root.facing == 1) {
_root.hero.gotoAndStop("jumpR")
} else if (_root.facing == 2) {
_root.hero.gotoAndStop("jumpL")}
if (_root.upheld == 2) {
if (_root.hero._y>_root.jumpvalue) {
if (_root.gravity > 1) {
_root.gravity-=.8}
_root.hero._y -= _root.gravity;
} else {
_root.jump = 3;}
} else {
if (_root.hero._y>_root.jumpvalue2) {
if (_root.gravity > 1) {
_root.gravity-=1.2}
_root.hero._y -= _root.gravity;
} else {
_root.jump = 3;}
}
}
}

onClipEvent (enterFrame) {
if (_root.jump==1) {
if (_root.hero.hitTest(_root.ground) == false) {
_root.hero._y = _root.hero._y+_root.jumpS;}

} else if (_root.jump==3) {
if (_root.hero.hitTest(_root.ground) == false) {
if (_root.gravity < _root.jumpS) {
_root.gravity+=1}
_root.hero._y = _root.hero._y+_root.gravity;
} else {
_root.jump = 1;
}
}
}


Thanks again and any help is appreciated.

Lewwy
July 14th, 2005, 08:21 AM
Woah, your still in school and you know all that !

I would love to learn how to create a game.. But learning what all that code means is gonna be tricky..

I think ill just make a character first..

You know any websites that could help me learn more about this?

dinner dog
July 14th, 2005, 12:00 PM
mate, i mean this in the best possible way but you are going the long way around about almost everything. but i am really impressed you got that much done on your own.

but you are definately using a lot of code for relatively easy tasks. this can be fixed pretty easy however and will, in the long run make the rest of your programming easier , and make asking questions easier as you have a lot of code and rough ways of implementing solutions that make it hard to track problems.

on that note i'll post an example in a minute or three of what you could do to simplyfy that code of yours but one of the biggest problems is you could/ should be moving the backgrounds with code (dynamicly) instead of with tweens as switching frames on a big image can be really processor intensive and can be confusing and hard to work with further down the line (and is probably causing the 'jump back' effect you have now). you could break the backgrounds down into chunks and move those with code.

tcooley2003
July 14th, 2005, 03:22 PM
Thank you for replying.

I am aware a lot of my coding is going the long way around things, but have not had anyone show me better ways of doing things as of yet. Posting examples of how to do things simpler instead of the long way around would help me out tremendously, and I appreciate it. The scrolling backgroud in tiles as you mentioned sounds like a solution to a lot of the problems I am having and an example of how to do this and implementing it would help the overall development of the game. I have a lot of coding issues that are going to be coming up so will be trolling the boards a lot probably lol.

Anyways, just thanking you again for your help and time invested into helping.

tcooley2003@yahoo.com

bandinopla
July 14th, 2005, 05:43 PM
Man, trie to write less... I can help you, but I dont goin to read all that... so we never know... JAJAJAJAJAJJAAJJAAJAJJJAJA (thunder thunger) JAJAJAJAJJAAJ ( a bat ) JAJAJAJAJAJJ (another bat AND a thunder that kill the bat) JAJAJAJJAJAJAJAJJAAJJAJAJAAJJJAAJAJAJAJAJAJAJAJAJA JJAJAJAJAAJA (A GIRL APPEARS) JAJAJAJAJAJ (... DOING) ajajaj. OK.