-
[F8] Fancy hants code
If you don't feel like reading my jargon just read the underlined text.
Hello all it's been a long time since I've posted any thing. Anyway I thank you for looking at my qustion. I'll get right to the matter. I'm building a game that I believe will be better than one of the greatest flash games to ever grace the internets, "Fancy Pants". What I have to ask is what frame rate do you all believe this game is running at ? Also I've been on the AS scene for some time now but, I think I could use some pointers on how to improve the speed of my code. Fancy Pants must have move code than my Alpha, why do you think his game run so fast?
my game:
Mr. White
my game runs @ 30 fps
Fancy Pants:
Fancy link
-
Lots of quick scrolling like that, without scaling and rotating - probably means they're using cacheAsBitmap.
-
thank you for the reply
I read about cacheAsBitmap and I understand what it does. Thank you lesli_felix I never used cacheAsBitmap and I think that this may be the answer. do you think that fancy pants used this method? I'll repost the Alpha with the cacheAsBitmap method.
-
It thinks its very likely. Moving large vector graphics around is much faster with cacheAsBitmap, provided they don't contain any animation, and don't get rotated or scaled. Basically, you can only move them around the stage, otherwise they get recached every frame which slows things down a lot.
-
Really nice game, I hope it does well :D One thing, if it is to compete with fancy pants, the character needs to be more agile and swift.
p.s. Hate to throw a spanner in the works but your fotter breaks FK's footer rules:
http://board.flashkit.com/board/showthread.php?t=710156
-
fancy pants link doesnt work for me, but i like the animation you have for your "Mr. White" game, thats all i can say since your link is broken, ill google it though
idk man, fancy pants is a pretty good game, do you think you'll be able to compare?
http://www.fancypantsadventures.com/
-
sorry
sorry about the link i added too many http:// in the address. Fancy Pants. thanks for the comments but as of now Mr. White can't come close to Fancy right now. You asked can I really make a game better than Fancy, well I feel like we all need to go for the stars and if we land in the clouds were still a lot higher than a lot of people and now were closer to the stars than we were before. I'm only a one man team, I make every thing from the ground up and I know fancy was build with a team. If I can out do them than I will know I'm a great programer.
-
I tryed what you told me and I've tryed to revamp my code I put a demo pack together and I'm hopping some one can tell me why my game lags so much. I put a txt file with the code in it, F8 ,MX fla, and a swf. Please take a look thank you.
download
in the code file
Code:
/*
level black engine (ver 2.1)
Demo
*****************************************************
by zervell:
Waarith Abdul-Majeed
Suger Cookie Games
2004-2006
*****************************************************
*/
stop();
var dx_speed:Number = 10;
var rkeyup:Boolean;
var lkeyup:Boolean;
var delta_x:Number = 0;
var delta_xm:Number = 0;
var gravity:Number = 0;
var dubjump:Boolean = false;
var offground:Boolean = false;
var jumping:Boolean = false;
var up_notpressed:Boolean = true;
var dub:Boolean = true;
hero.cacheAsBitmap = true;
land.cacheAsBitmap = true;
/*
ver 1.0 onEnterFrame()
*/
function onEnterFrame() {
void camera_plat();
void movementx();
void movementy();
void movementstop();
}
/*
ver 2.0 Movementx()
*/
function movementx() {
var friction:Number = .5;
hero._x += delta_xm;
delta_xm = Math.round(delta_x);
if (Key.isDown(Key.RIGHT)) {
hero._xscale = 100;
delta_x += 2;
rkeyup = false;
} else {
rkeyup = true;
}
if (Key.isDown(Key.LEFT)) {
hero._xscale = -100;
delta_x -= 2;
lkeyup = false;
} else {
lkeyup = true;
}
(delta_x>dx_speed) ? delta_x=dx_speed : 0;
(delta_x<-dx_speed) ? delta_x=-dx_speed : 0;
(delta_xm>0) ? delta_x -= friction : 0;
(delta_xm<0) ? delta_x += friction : 0;
return;
}
/*
ver 2.5 movementy()
*/
function movementy() {
hero._y += gravity;
if (!land.hitTest(hero._x, hero._y, true)) {
gravity += 1;
offground = true;
}
if (Key.isDown(Key.UP)) {
if (!offground) {
hero._y -= 5;
gravity = -15;
jumping = true;
up_notpressed = false;
}
} else {
up_notpressed = true;
}
if (Key.isDown(Key.UP) && jumping && up_notpressed && !dub) {
gravity = -15;
dub = true;
}
if (gravity>=15) {
gravity = 15;
}
return;
}
/*
ver 2.5 movementstop()
*/
function movementstop() {
//x movement control
while (land.hitTest(hero._x+16, hero._y-20, true)) {
hero._x -= 1;
delta_x = 0;
}
while (land.hitTest(hero._x-16, hero._y-20, true)) {
hero._x += 1;
delta_x = 0;
}
//y movement control
if (land.hitTest(hero._x, hero._y-40, true)) {
hero._y += 5;
gravity = 5;
}
while (land.hitTest(hero._x, hero._y, true)) {
gravity = 4;
hero._y -= 1;
dub = false;
offground = false;
jumping = false;
}
return;
}
/*
ver 2.9 camera_plat
*/
function camera_plat() {
//y control
var camera_y:Number;
camera_y = Math.round(((hero._y-20)-(Stage.height/2))/5);
hero._y -= camera_y;
land._y -= camera_y;
(camera_y>10) ? camera_y=10 : (camera_y<-10) ? camera_y=-10 : 0;
abs_delta_xm = Math.abs(delta_xm);
//y control
hero._x -= Math.round(((hero._x)-(Stage.width/2))/10);
land._x -= Math.round(((hero._x)-(Stage.width/2))/10);
}