omega10mg
09-27-2003, 08:28 PM
so i'm trying to make my own platformgame engine. :p
it dosent work the way i want.. lets look at the code then i explain what dosent work.
//ON HERO MOVIECLIP
onClipEvent (load) {
yjump = 20;
xwalk = 4;
rightedge = 550;
leftedge = 0;
xspeed = 20;
yspeed = 20;
gravity = 2;
drag = .98;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= yjump;
}
if (Key.isDown(Key.RIGHT)) {
_x += xwalk;
}
if (Key.isDown(Key.LEFT)) {
_x -= xwalk;
}
_x = _x+xspeed;
if (_x+_width/2>rightedge) {
_x = rightedge-_width/2;
xspeed = -xspeed;
}
if (_x-_width/2<leftedge) {
_x = leftedge+_width/2;
xspeed = -xspeed;
}
_y = _y+yspeed;
yspeed = yspeed*drag+gravity;
xspeed = xspeed*drag;
}
//ON GROUND MOVIECLIP
onClipEvent (enterFrame) {
if (this.hitTest(_root.hero)) {
tellTarget (_root.hero) {
yspeed = 0;
xspeed = xspeed*0.50;
}
}
}
okey.. often u fall half way down the ground! hum.. any idea on how to fix this?
and i have to hold up to jump elsewise it just falls down real quick.. anyway to make it jump all the way?
and how would i make diffrent animations play when i press left, right and up.
I tryed to to use gotoAndStop(aframe) and on the specific frame i had a movie clip with the correct animation.. but this did not work very well... it was hard to have the guy point at the right direction when he was walking right then jumping etc.
and the last thing.. do u think my idea on this platform engine is anygood?
it dosent work the way i want.. lets look at the code then i explain what dosent work.
//ON HERO MOVIECLIP
onClipEvent (load) {
yjump = 20;
xwalk = 4;
rightedge = 550;
leftedge = 0;
xspeed = 20;
yspeed = 20;
gravity = 2;
drag = .98;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= yjump;
}
if (Key.isDown(Key.RIGHT)) {
_x += xwalk;
}
if (Key.isDown(Key.LEFT)) {
_x -= xwalk;
}
_x = _x+xspeed;
if (_x+_width/2>rightedge) {
_x = rightedge-_width/2;
xspeed = -xspeed;
}
if (_x-_width/2<leftedge) {
_x = leftedge+_width/2;
xspeed = -xspeed;
}
_y = _y+yspeed;
yspeed = yspeed*drag+gravity;
xspeed = xspeed*drag;
}
//ON GROUND MOVIECLIP
onClipEvent (enterFrame) {
if (this.hitTest(_root.hero)) {
tellTarget (_root.hero) {
yspeed = 0;
xspeed = xspeed*0.50;
}
}
}
okey.. often u fall half way down the ground! hum.. any idea on how to fix this?
and i have to hold up to jump elsewise it just falls down real quick.. anyway to make it jump all the way?
and how would i make diffrent animations play when i press left, right and up.
I tryed to to use gotoAndStop(aframe) and on the specific frame i had a movie clip with the correct animation.. but this did not work very well... it was hard to have the guy point at the right direction when he was walking right then jumping etc.
and the last thing.. do u think my idea on this platform engine is anygood?