hopefully someone is nice enough to donate a little time to get my "megaman-esque" engine started off the ground. Im not really that good because there really are no tutorials for fenix/bennu. I need help with fenix first, because in my introduction to these forums, I stated im making a dreamcast homebrew game (and there no bennu for dremacast D:) so the only way I can make it is with fenix, then when I get to the pc ill upgrade it into bennu (sounds fair enough, dont you think?). Seeing as though the two are similar (in what I need help with, im sure some of you know how to use fenix), thats why i cam here, booleansoup was too lazy to help, and most, if not all other forums are lazy too. I will make a double post (the second will have my code). The problems I am having though are:
*the character animaton doesnt work right, that whole area is "unpolished" because ive messed with the code so much there so the whole animation thing is incomplete (cause I was tweaking and someone closed out so I couldn't undo anything). i just want it to through frames (or graphs) 3,4,5,4,3,4,5,4, etc, etc.
*I cant get the jump graph to stay while hes jumping. The walk animation takes over if i move, and besides that the jump animation last about a split second. you'll see what I mean.
*I have the ground set to specific coordinates; how can I make the ground appear as an image (a mask, if you will) and he collides with anything thats not transparent (even though the image is invisible, like a mask), I set the character to spawn higher than the ground, but he didnt fall until i jumped.
thats all i need help with for now. :) thanks
Program platform_engine;
Global
Playerfpg;
Ground_height=200;
Begin
Set_mode(320,240,8);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
Player(PlayerFPG,1,50,200);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
jump=0;
player_animation[] = 3,4,5,4;
Begin
Loop
// Walking
If (key(_left) or key(_right))
If (graph==1)
graph=player_animation;
End
If (key(_left)-key(_right)>0)
flags=1;
x-=xspeed;
Else
flags=0;
x+=xspeed;
End
Else
// Standing still
graph=1;
End
// Jumping
If (jump==0)
If(key(_space))
jump=1;
y_acceleration=y_start_acceleration;
End
Else
y_acceleration-=1;
If (y=>ground_height)
jump=0;
y=ground_height;
y_acceleration=0;
yspeed=0;
End
End
yspeed+=y_acceleration;
y-=yspeed;
Frame;
End
End
You have an error:
If (key(_left)-key(_right)>0)
flags=1;
x-=xspeed;
Else
please
add
code tag on your game source
use
[.code]
whithout dot
ok ill do that next time. and FreeYourMind, what do you mean by error? could you show me whats correct then?
key(left)-key(right)>0
its no sense
whit - you mean AND ?
what you want to do whit >0?
The best way to work with animations (I supose) its to work with character status: create a private variable, like "char_status", and give it values, 0 if it stands, 1 if it walks, 2 if it jumps.
Then, almost finishing the main loop of your character process, use a switch-case with "char_status" to change GRAPH.
You can use more variables if an animation secuence has more status, delay, or else.
Separate the graph section helps you if you need to add more status or change graphics.
With collision, i don't like to use collision with a big map, we recomend to use "hardness maps", they are maps stored in memory (loaded, but not assigned to a process). Then you can use map_get_pixel function to get a pixel from this map and act as you need.
Quote from: Zip on March 04, 2011, 01:20:47 PM
key(left)-key(right)>0
its no sense
whit - you mean AND ?
what you want to do whit >0?
I have no idea, someone on booleansoup told me to use that code. it works though.
i never worked in Fenix but i so strange that code :-[
if it work ok..
for animation you have seen yet the "taller fenix" example?
that..
ps: why The .7z format is not allowed T_T
[code language="fenix"]
Program platform_engine;
Global
Playerfpg;
Ground_height=200;
//initializes the player's sprites
int Player_graph[5];
//initializes the level
int level;
int levelmask;
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
// PlayerWalk Animations
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk2.png");
Player_graph[2]=load_png(".\sprites\player\Walk3.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Stand.png");
Player_graph[5]=load_png(".\sprites\player\Jump.png");
Player(PlayerFPG,1,50,200);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
jump=0;
int i;
int ii;
Begin
Loop
// Walking
If (key(_left) or key(_right))
If (graph==Player_graph[4])
graph=Player_graph
;;
//Animation for movement - thru [3]
i=(i+1)%4;
End
If (key(_left)-key(_right)>0)
flags=1;
x-=xspeed;
Else
flags=0;
x+=xspeed;
End
Else
// Standing still
graph=Player_Graph[4];
End
// Jumping
If (jump==0)
If(key(_space))
jump=1;
graph=Player_Graph[5];
y_acceleration=y_start_acceleration;
End
Else
y_acceleration-=1;
If (y=>ground_height)
jump=0;
y=ground_height;
y_acceleration=0;
yspeed=0;
End
End
yspeed+=y_acceleration;
y-=yspeed;
Frame;
End
End
[/code]
Ok I got stuff working. However, heres my issue:
*I try to get the walking animation to work, but it does only 1 of the 4, its not animation (i wish there was a load_gif feature)
*I took some code from the taller fenix to make stuff simpler, but it makes the game freeze upon starting up (look in caydaysalto.prg from lines 144 -> 153)
*I figured out a jump thing where in the "//standing still" part of my code i put if(jump==0) and it worked, however pressing right or left crashed the game.
so im stuck.
try to use separated control
If (key(_left)
flags=1;
x-=xspeed;
end
if (key(_right)
flags=0;
x+=xspeed;
End
If (graph==Player_graph[4])
graph=Player_graph[i];;
//Animation for movement [0] thru [3]
i=(i+1)%4;
End
You only enter this code one time, just before your character is standing. Check the IF condition (maybe you don't need it) if you want to access it every frame.
it works perfectly. testing it on the dreamcast however, the .pngs did not show up. how can i make the "./.png" part of the code become a graph from an .fpg?
you use fpg or png for graphix?
You can create FPGs with FPGEdit, FPGEdit2009 or your own aplication using FPG_ADD y SAVE_FPG on PC (there are other aplications, but they arent finished or don't remember its name ^^U).
the code i posted has them listed as .png. i know how to use fpgedit2005
Ive got a perfectly walking megaman and the level. Im still stuck with the jump animation (it still shows for a split second then goes back to standing/walking) and my character cant run into the red walls i planted in the level, i had them coded in at some point, but the game crashed and i took out so much code the program itself crashed so i lost it inbetween the craks. could you fix those two meesly things?
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(256,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
jump=0;
int i;
int ii;
int pixel;
int red,blue,green;
Begin
ctype=c_scroll;
Loop
// Walking
If (key(_left) or key(_right))
If (graph==Player_graph[12])
graph=Player_graph
;
//Animation for movement - thru [11] - 12 frames of animation
i=(i+1)%12;
End
If (key(_left))
flags=1;
x-=xspeed;
graph=Player_graph;;
//Animation for movement - thru [11] - 12 frames of animation
i=(i+1)%12;
End
if (key(_right))
flags=0;
x+=xspeed;
graph=Player_graph;;
//Animation for movement - thru [11] - 12 frames of animation
i=(i+1)%12;
End
Else
// Standing still
graph=Player_Graph[12];
End
// Jumping
if (key (_space))
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
graph=Player_graph[13];
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
else
fall = 0;
end
Frame;
End
End
[/code]
can u post the complete game whit graph and all the rest?
thanx
Its because you press left or right button: then you assign to graph a new image.
flags=1;
x-=xspeed;
graph=Player_graph[ i ];;
So you get the graph of walking. Later you don't assign to graph the jump graphic (just only if you push space). You must assign graph again on jumping routine.
This is why I recomended to use a status variable: at the end of your character main loop, you can check if Player is walking, jumping or fireing, so you assign the graph you need once in a loop round.
Quote from: Zip on March 10, 2011, 12:58:55 PM
can u post the complete game whit graph and all the rest?
thanx
thats the whole code
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
jump=0;
int i;
int ii;
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping
Begin
ctype=c_scroll;
Loop
// Walking
If (key(_left) or key(_right))
If (graph==Player_graph[12])
graph=Player_graph
;
//Animation for movement - thru [11] - 12 frames of animation
i=(i+1)%12;
End
If (key(_left))
flags=1;
x-=xspeed;
player_status=1;
End
if (key(_right))
flags=0;
x+=xspeed;
player_status=1;
End
Else
// Standing still
player_status = 0;
End
// Jumping
if (key (_space))
player_status=2;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
else
fall = 0;
end
//Player Status
if(player_status==0)
graph=graph=Player_graph[12];
end
if(player_status==1)
graph=graph=Player_graph;
i=(i+1)%12;
end
if(player_status==2)
graph=graph=Player_graph[13];
end
Frame;
End
End
[/code]
problems now:
*still the jump thing. i put the status in the jump and in the fall and heres the outcome:
in both jump and fall: it flickers between the standing sprite and the jumping sprite
in jump only: it flashes for a second but now if i hold down space, you see it as long as space is held down
in fall only: thats the only sprite you see
*and meeting with the red.
thats the whole code, im sure if you test the code you can use whatever you want for images. its just megaman stuff im using.
and: how can i turn the .pngs into fpg's? im not talking about using fpgedit, im talking about in the code itself. i know how to put one in there. but with the code i have out, can i just change the ".png" to a graph from an fpg? same thing for the level, the dreamcast crashes upon png_load
You got the same problem than before, just think about this:
-If you don't move, your character will be on status=0.
-If you walk, you have status=1. Ok, no problem.
-If you hit space without moving, first you get status=0, and then, status=2, in the same frame. Ok.
-But if later you release the space button, yes, you are still jumping, but the "If (key(_left) or key(_right))" put status to 0 or 1, so when you reach the "graph control block" it looks for stand or walking animation. You must put status to 2 if you are jumping but not pressing space, or not assign status 0 or 1 if you are previously jumping.
About FPG, as I said later, you got FPG_ADD and SAVE_FPG to add a loaded/created map to a virtual FPG (you can create a new FPG with NEW_FPG) and to save it to disk. Just load your PNG as usual, and use its ID to put it in the FPG.
I recommend virtual fpg's, too. It's very handy, and you can also save them to disk from your bennu program.
It is possible to create a full-blown fpg manager. Also, you have the added benifit of using controlpoints.
ok... :-\ im getting very flustered now. It could be the fact that i have an illness in my sinuses which lately have been giving me headaches to where i cant grasp many things or it could be soemthing else. but i cant get this to work how i want it. one line will cripple the entire code. I hate that. Im gonna repost the code where its at. can you please (please) just show me where to change the status (repost the code with it in there please). ive literally gone through every line and pasted it there, it always flickers or flashes for a split second... thnak you:
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
jump=0;
int i;
int ii;
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping
Begin
ctype=c_scroll;
Loop
// Walking
If (key(_left) or key(_right))
player_status=1;
If (key(_left))
flags=1;
x-=xspeed;
player_status=1;
End
if (key(_right))
flags=0;
x+=xspeed;
player_status=1;
End
Else
// Standing still
player_status = 0;
End
// Jumping
if (key (_space))
player_status=2;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
else
fall = 0;
end
//Player Status
if(player_status==0)
graph=graph=Player_graph[12];
end
if(player_status==1)
graph=graph=Player_graph;
i=(i+1)%12;
end
if(player_status==2)
graph=graph=Player_graph[13];
end
Frame;
End
End
[/code]
First, I'd recommend using symbolic constants for the player status. This will clearify the code when you read it over.
So, in the beginning of the program put:
CONST
STANDING=0;
WALKING=1;
JUMPING=2;
No, anywhere you read or write status you could type: player_status=WALKING;
Or in tests, IF (player_status==JUMPING) etc.
This will really come in handy some day, because it reduces the need to memorize wich is wich,
and the code is more readable. Believe me, you'll be able to spot bugs or logic errors faster this way.
Second, I highly discourage using one/two character variables, just give them meaningfull names.
Basically for the same reason that it's easier in code reviews. I see you've already made fairly decent
use of that. But I can't tell the difference between i and ii, but I'll guess they are counters.
Third, use the "say" function anywhere in your code where you feel something special happens. This
will also speed up finding logic errors. (Say is like printf so you can output values and anything you
like on the dos console).
Also, try changing variables at run time with the bennu debug console.
But why not use some existing code? Just have a look at the code from malvado, it's suitable for almost
any platform game variant, especially if you tweek it a little bit. I've used the malvado code in a lot of
projects in the past before I ported it to bennu.
But, I think the best thing to do is to do code reviews and debugging. What helps for me when I get stuck
is to go outside, walk around the block or take a ride on my bike and think on a more conceptual level about
the logic or certain patterns, and then come back at the code. I get the solution usally when I'm not behind
the computer.
i tried that and none of it helped. you also have to remember im using fenix .84 for dreamcast. id really like someone to take my code, and put it in for me so i know later on. but thanks
Fenix 0.84 is ancient......(and buggy).
I thought there was a newer dreamcast version, 0.89 or 0.90?
I'm not really sure.
i found a .93 beta someone released but can you change my code?
I have no idea how to get it from this site:
http://www.dc-swat.ru/page/fenix/ its in russian.
but for now, im staying with 0.84
but please, im begging you. i have no more time to spare to figure out how to make the player work. if i can get the collision with red to stop him and the jump sprite to work properly then I am good. i somewhat have a deadline and there really are no tutorials for div/fenix/bennu. so if someone will humbly add those things to my code and repost it, i would like that.
pero por favor, soy lo ruego. no tengo más tiempo de sobra para encontrar la manera de hacer que el jugador trabajo. si puedo conseguir la colisión con el rojo a detenerlo y el salto de sprite para que funcione correctamente, entonces estoy bien. i tienen una fecha límite y no hay realmente no hay tutoriales para div / Fenix / Bennu. así que si alguien puede hacer eso por mí, yo le agradecería
The key is in this part:
[code language="fenix"]
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
else
fall = 0;
end[/code]
You did two separated IFs to jump state (for ascending and falling)... or I think they are, so you must put inside of both if the jumping state (or ascending and falling state if you gonna use two separated graphs/animations).
I'm not sure how you implement this (is kinda confusing using i or ii as variables), but i think you must do this:
[code language="fenix"]
// Implementation of fall.
ii = fall;
if(ii > 0)
player_status=JUMPING_STATE;
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
player_status=FALLIN_STATUS;
else
fall = 0;
end[/code]
I said before, you only assigned the jumping status if you are pressing space, because you enter on key(_space) if, but if you release it, from there to end you don't assigned a new status and hold the previous: standing or walking (the two previous IFs).
with what you put in, thats the only sprite you see. so it needs to go back to stand when it lands. I have no idea how to put in the names for the status so youll have to show me where (im guessing its under "int player_status")
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
jump=0;
int i;
int ii;
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling
Begin
ctype=c_scroll;
Loop
// Walking
If (key(_left) or key(_right))
player_status=1;
If (key(_left))
flags=1;
x-=xspeed;
player_status=1;
End
if (key(_right))
flags=0;
x+=xspeed;
player_status=1;
End
Else
// Standing still
player_status = 0;
End
// Jumping
if (key (_space))
player_status=2;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
player_status=2;
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
player_status=3;
else
fall = 0;
end
//Player Status
if(player_status==0)
graph=graph=Player_graph[12];
end
if(player_status==1)
graph=graph=Player_graph;
i=(i+1)%12;
end
if(player_status==2)
graph=graph=Player_graph[13];
end
if(player_status==3)
graph=graph=Player_graph[13];
end
Frame;
End
End
[/code]
so at elast the code got somewhere after several days of asking. but i have no idea with it going back to stand.
Quote from: DoctorN on March 13, 2011, 03:32:38 AM
with what you put in, thats the only sprite you see.
What sprite?
Quote from: DoctorN on March 13, 2011, 03:32:38 AM
I have no idea how to put in the names for the status so youll have to show me where (im guessing its under "int player_status")
I put names because i don't know what numbers are you using for every status. Don't take all we say literally, don't use copy/paste, just read, analyze, think about it and then write your own code.
We cannot code for you.
Quote from: DoctorN on March 13, 2011, 03:32:38 AM
so at elast the code got somewhere after several days of asking. but i have no idea with it going back to stand.
If you don't know what are you doing or you are going to do several changes in code, try to keep differents versions of your code, so if you do something wrong, you always can come back.
Try to write your code on paper, or do an schematic flow, and try to do it line by line. Don't try to force what you want to do it, just follow the code. It's slow and tedious, but you need to do it the firsts times until you know how to do it without paper.
There must be some examples (in Bennupack, in "catle of dr. Malvado" or other games, like "the amazing adventures of Echo"), so if you're lost, try to read o try another game more simple (a platform game is not recomended for noobs).
im not a noob, im an expert at gml and actionscript 2-3 and something so simple doesnt even compute anymore. im sure you know what sprite im talking about (there is only ONE sprite I am talking about) and thats the jump sprite. I dont want to modify a finished game because its so clustered with stuff that I dont even want (and remember, fenix .84b for dreamcast). that really makes no sense to jot stuff down on paper. im just so flustered because of all the time i have wasted for this deadline, its taken me a week to try and get this jump part to work properly, i still want someone to help me with the red collision, but its like nothings been happening. so please, read my code, it should say everything in the //comments.
Hey, calm down.
Getting started with a new languaje is not easy and take time and lots of easy and simple programs to get practice. You know GML (game maker languaje, i supose) and actionscript, but i know C, ASM, Matlab, Div, Fenix and now java (starting) so i know how first programs are, because none of them its the same.
Bennu is a process languaje, so if you haven't programmed in C with processes, you cannot call yourself an expert in Bennu. Concurrent programming is not the same as secuencial programming.
Don't think always that we know what are you thinking, because i didn't know if you were talking about standing sprite or walking sprite, but you told me about jumping sprite.
And i read your code, but i'm little limited for what I read.
I'm helping you because i had a little time to spend with you, i don't know others, but if you don't calm, i can't help you. I have lots of things to do too.
One week for first character, walking, jumping and more on hardness map for first bennu program i think its short time. Last character I made tooks me about a week with written code and years of experience, so keep going.
So, for now i will told you two questions to give some clues:
-in "If (key(_left) or key(_right))" block, you put "player_status=1;" 3 times, but they are redundant. You can delete, one or two if you do it right.
-You said that you always see the jump sprite but, can you tell me what's the player_status who do it? it tells you where is the problem.
I give clues to help, I don't write code for others (unless it can help many people). Correct your own errors is the best way to learn, that's what I think, but if you want written code, i'm the wrong guy. Ask another one or copy other code.
i also did visual basic and xna.
if you read the comments next to int player_status it should say
0 - standing
1 - walking
2 - jumping
3 - landing
also, how does the status 1 thing mean anything. i dont really see how it corresponds to jumping, or collision with the colour red.
pay close attention to line 75 it should tell you everything in the //comment
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
jump=0;
int i;
int ii;
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling
Begin
ctype=c_scroll;
Loop
//Player Movement
if (key (_left))
flags = 1;
ii = 0;
while (ii <5)
pixel = map_get_pixel(0, levelmask, x-ii, y);
get_rgb (pixel, & red, & green, & blue);
if (red> 200)
ii = ii - 1;
break;
end
ii = ii +1;
end
x = x-ii;
end
if (key (_right))
flags = 0;
ii = 0;
while (ii <5)
pixel = map_get_pixel(0, levelmask, x + ii, y);
get_rgb (pixel, & red, & green, & blue);
if (red> 200)
ii = ii - 1;
break;
end
ii = ii +1;
end
x = x + ii;
end
// Players Status
if ((!key (_left)) and (!key (_right)))
player_status=0;
else
player_status=1;
end
// Jumping
if (key (_space))
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
ii = ii + 1;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);;
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
else
fall = 0;
end
//Player Status
if(player_status==0)
graph=graph=Player_graph[12];
end
if(player_status==1)
graph=graph=Player_graph;
i=(i+1)%12;
end
if(player_status==2)
graph=graph=Player_graph[13];
end
if(player_status==3)
graph=graph=Player_graph[13];
end
Frame;
End
End
[/code]
I took out the jumping for now, and I got rid of the two uneeded status thingamagigers in the left and right stuff (if it made any difference). at the very best so i can explain jumping let me lay it out for you:
*if set in the right place, the jumping sprite will be the only thing you see
*if set right after jump, it will flash for a second then proceed back to status 0 (standing) or status 1 (walking)
*if set in landing only (i forget most of this, but even somewhere in jumping too as i recall), it will flicker between the jump sprite, and whatever else is happening (standing/walking).
i hope that explains everything
EDIT: got the red collision to work :). still need help with that jump though
Let's go step by step.
The jump code it this?
[code language="fenix"]
// Jumping
if (key (_space))
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
[/code]
As I understand, it only jumps (and elevate) if space key is pressed, right?
yes...
don't you have bennu/fenix on your computer?
Yes, i have, but it's 2:00am here, and don't have your graphics.
Ok, if this is the jump code, put in the jump player_status:
[code language="fenix"]
// Jumping
if (key (_space))
player_status=2;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
[/code]
If it works, tell me the code who make the player falls until it reachs the floor.
all the graphics are are sprites of megaman: (but because im not just unpack this into the platform_engine folder and the code will work)
http://www.mediafire.com/?5sb855p5o0u5b8b
I had the status thing in there, and in //implementation of fall but it was one of the mentioned above:
Quote from: DoctorN on March 14, 2011, 01:54:36 AM
*if set in the right place, the jumping sprite will be the only thing you see
*if set right after jump, it will flash for a second then proceed back to status 0 (standing) or status 1 (walking)
*if set in landing only (i forget most of this, but even somewhere in jumping too as i recall), it will flicker between the jump sprite, and whatever else is happening (standing/walking).
Ok, I could test your code and i made the needed changes, but do not get used to get so explicit answers ;)
[code language="bennu"]Program platform_engine;
//these are global variables
Global
Playerfpg;
//initializes the player's sprites
int Player_graph[14];
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
PlayerFPG=load_fpg("Player.fpg");
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_grap[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
level=load_png(".\sprites\level\image\test.png");
levelmask=load_png(".\sprites\level\mask\test.png");
Player(PlayerFPG,1,50,100);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(file,graph,x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
int falling; //indicate if character is in falling mode or not
jump=0;
int i;
int ii; //you must say: counter to test every pixel of movement of hardness map
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling
Begin
ctype=c_scroll;
Loop
//Player Movement
if (key (_left))
flags = 1;
ii = 0;
while (ii <5)
pixel = map_get_pixel(0, levelmask, x-ii, y);
get_rgb (pixel, & red, & green, & blue);
if (red>200)
ii = ii - 1;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x-ii;
end
if (key (_right))
flags = 0;
ii = 0;
while (ii <5)
pixel = map_get_pixel(0, levelmask, x + ii, y);
get_rgb (pixel, & red, & green, & blue);
if (red>200)
ii = ii - 1;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x + ii;
end
if (!key(_left) and !key(_right) and player_status==1)
player_status=0;
end
// Jumping
if (key (_space))
player_status=2;
falling=true;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = ii + 1;
falling=false;
say("I'm in ground now");
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
//Ending of jumping and falling status
say("FALLING: "+falling+" Player status: "+player_status);
if (player_status==2 and !key(_space)) player_status=3; end
if (player_status==3 and !falling) player_status=0; end
// Acceleration of gravity
if (ii == 0)
fall = fall + 5;
falling=true;
else
fall = 0;
end
//Player Status
//say(player_status);
switch (player_status)
case 0: graph=Player_graph[12]; end
case 1:
graph=Player_graph;
i=(i+1)%12;
end
case 2: graph=Player_graph[13]; end
case 3: graph=Player_graph[13]; end
end
//say("frame");
Frame;
End
End
[/code]
First, as i said, you must comment the ii use, I cannot understand his use untill several reads (maybe you are one of a few peolple who used a loop to check every pixel on hardness map movement :P)
I added a new variable who indicates if character is falling or not. I'm not sure if you can do this in another way (checking vertical speed or else), I did this way.
Then I can add the player_status statements and his changes. Maybe, make a status flow and its possibles changes in paper can help to do this.
I left some SAY statements to show you some tips for debug, you can delete them if you want. You'd better watch what really variables has, not what you thinking it had, usually they are differents ;)
And there are minor changes, but it's because I'm used to it.
I hope it helps to you, I'm waiting to se your project finished.
By the way:
You don't need to load the same graphic many times, you can:
-Have a list of mpas loaded, and another list with animations, where you can repeat the same map_id without having it on memory twice.
-Create a counter to check animation delay: if it reachs 3 (or another number), put it to 0 and advance an animation frame. But you must put it to 0 every time you change player_status.
thanks :) and technically you did help others because they can download those sprites and use the code thats on this thread to start their platform engine XD
Anyone got any idea how to do "layers" i want my player to be in front of everything else with the level being the layer behind everything.
Layers... Well, graphs from processes have a z-value. The mouse cursor has a predifined z-value of -512. This means that it is on the topmost layer.
This is the range of layer depth: -etc -etc -512 -200 -100 0 100 200 etc etc 512 etc, so to put something behind an other object, use values like 100 or 200, and to bring stuff to the front you add a minus to the number. (I'm not really sure what the maximum and minimum value's of the range are, but hese should be fine).
Scrolls have a predifined z value, too. You can freely change those values in case you want to do special things. In case you feel restricted by the standard scrolls, you can create your own scroll layers by using some of the more advanced features of the scroll structure. This advanced feature allows to manually manipulate the scroll window and the speed ratio of the layers but, this is a rather sophisticated feature that I don't recommend for beginners. (Once you know more about the language you can delve into these things).
I just did z = 100; and z=-100; and tried them between the two and nothing happened. the game still played so i dont think i did an error but is it harder than that? i know in adobe flash and actionscript you can just say layer = 1 or soemthing
Where in the code did you exactly put this the z-value?
It should preferrably in the begin section of a process. You can also pass it as an argument.
Try adding some code in the process that you want to have a different z-value:
IF (key(_z))
FRAME (100);
say ("z="+z);
z-=100;
say("z changed to: "+z);
END
IF (key(_x))
FRAME (100);
say ("z="+z);
z=100;
say("z changed to: "+z);
END
(put this somewhere in the player's process if it's the player's process you want to alter the z of)
obviously this only has affect if you do something similair in other processes.
I put it right after Process Player and Process Enemy as seen in my whole list of code (fully functional except for the layer thing, feel free to copy it and use it)
just look for the Processes, I would literally put (without the quotes) "z=100", "z+=100", "z-=100", or "z=-100" to try each one out underneath the private (which is
underneath the process's)
[code language="fenix"]
Program platform_engine;
//these are global variables
Global
//initializes the player's sprites
int Player_graph[14];
//initializes the enemy(s) sprites
//letter of alphabet sorts out the enemies
int enemy_x_graph[12];
//initializes the collectibles sprites
int item_graph;
//initializes the level
int level;
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_graph[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
//animations for the enemy(s)
enemy_x_graph[0]=load_png(".\sprites\enemies\x1.png");
enemy_x_graph[1]=load_png(".\sprites\enemies\x1.png");
enemy_x_graph[2]=load_png(".\sprites\enemies\x1.png");
enemy_x_graph[3]=load_png(".\sprites\enemies\x2.png");
enemy_x_graph[4]=load_png(".\sprites\enemies\x2.png");
enemy_x_graph[5]=load_png(".\sprites\enemies\x2.png");
enemy_x_graph[6]=load_png(".\sprites\enemies\x3.png");
enemy_x_graph[7]=load_png(".\sprites\enemies\x3.png");
enemy_x_graph[8]=load_png(".\sprites\enemies\x3.png");
enemy_x_graph[9]=load_png(".\sprites\enemies\x2.png");
enemy_x_graph[10]=load_png(".\sprites\enemies\x2.png");
enemy_x_graph[11]=load_png(".\sprites\enemies\x2.png");
//sets the image for the collectibles
item_graph=load_png(".\sprites\collectibles\pellet.png");
//sets the levels background images
level=load_png(".\sprites\level\image\test-1.png");
levelmask=load_png(".\sprites\level\mask\test-1.png");
Player(50,100);
EnemyX(290,100);
Item(100,200);
Item(116,200);
Item(132,200);
Item(148,200);
start_scroll(0,0,level,0,0,0);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for the player, all code that belongs to him is in this part
Process Player(x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
int falling; //indicate if character is in falling mode or not
jump=0;
int i;
int ii; //you must say: counter to test every pixel of movement of hardness map
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling
Begin
ctype=c_scroll;
Loop
//Player Movement
if (key (_left))
flags = 1;
ii = 0;
while (ii <4)
pixel = map_get_pixel(0, levelmask, x-16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = 0;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x-ii;
end
if (key (_right))
flags = 0;
ii = 0;
while (ii <4)
pixel = map_get_pixel(0, levelmask, x + 16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = 0;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x + ii;
end
if (!key(_left) and !key(_right) and player_status==1)
player_status=0;
end
// Jumping
if (key (_space))
player_status=2;
falling=true;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue> 200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = ii + 1;
falling=false;
say("I'm in ground now");
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
//Ending of jumping and falling status
say("FALLING: "+falling+" Player status: "+player_status);
if (player_status==2 and !key(_space)) player_status=3; end
if (player_status==3 and !falling) player_status=0; end
// Acceleration of gravity
if (ii == 0)
fall = fall + 3;
falling=true;
else
fall = 0;
end
//Player Status
//say(player_status);
switch (player_status)
case 0: graph=Player_graph[12]; end
case 1:
graph=Player_graph;
i=(i+1)%12;
end
case 2: graph=Player_graph[13]; end
case 3: graph=Player_graph[13]; end
end
//say("frame");
Frame;
end
end
Process EnemyX (x,y)
private
int i;
int ii;
int Xini;
int fall;
int falling;
int pixel;
int red,blue,green;
int inactive;
begin
Xini = x;
ctype = c_scroll;
loop
if(flags == 0)
ii = 0;
while (ii <3)
pixel = map_get_pixel(0, levelmask, x + 16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = 0;
flags = 1;
break;
end
ii = ii + 1;
end
x = x + ii;
else
if(flags == 1)
ii = 0;
while (ii <3)
pixel = map_get_pixel(0, levelmask, x-16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = 0;
flags = 0;
break;
end
ii = ii + 1;
end
x = x-ii;
end
end
i = i +1;
graph = enemy_x_graph [i%12];
falling=true;
if (inactive==0)
falling=true;
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue>200)
ii = ii + 1;
falling=false;
say("I'm in ground now");
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
// Acceleration of gravity
if (ii == 0)
fall = fall + 3;
falling=true;
else
fall = 0;
end
frame;
end
end
process item(x,y)
begin
ctype=c_scroll;
graph=item_graph;
loop
if(collision(type player))
break;
end
frame;
end
end
[/code]
Any idea how I can finish my scrolling thingy? i just need it to center follow (horizontally) the player. my hard drive crashed so i have an older version and i forgot the scrolling >.<
Program platform_engine;
//these are global variables
Global
//initializes the player's sprites
int Player_graph[14];
//initializes the enemy(s) sprites
//letter of alphabet sorts out the enemies
int enemy_x_graph[12];
//initializes the collectibles sprites
int pellet_graph[1];
//initializes the levels images
int level_graph[2];
//initializes the levelmask
int levelmask;
//this sets up things like the games resolution and whatnot
Begin
Set_mode(320,240,16);
Set_fps(20,0);
Map_clear(0,0,RGB(0,0,0));
Write (0, 64, 16, 1, "Platform Game");
//Starts the scroller
scroller();
//starts the levelmask (par on with the scroller, but is the mask for the levels)
level_mask();
//players fpg, and position
Player(50,100);
//enemy(s) fpg, and position
EnemyX(260,100);
//collectibles fpg, and position
pellet(100,200);
pellet(116,200);
pellet(132,200);
pellet(148,200);
Loop
If (key(_esc))
Exit("Bye",0);
End
Frame;
End
End
//This process is for all the levels, menu's, and cutscenes
Process scroller()
Begin
level_graph[0]=load_png(".\sprites\level\image\testlevel.png");
start_scroll(0,Player_graph,level_graph,0,0,1);//starts the scroll, variables:
/*
0: number of scroll, 0-9 are possible, this is the first one, so 0 :)
player_graph: the object/sprite that the scroller will follow
level_graph: the map in the library chosen
0: a background for the scroll you can choose (kind of second image scrolling
with the same parameters, but not necessarily the same way, and in behind the previously
selected image
0:is the part of the screen the scroll is shown in, 0 is default region, the entire screen
you can use this if you want to limit the size of the scrol (not in behind a menu or so)
for performance issues i guess, thigns on the scroll also won't show outside the region.
make sure you give your new regiona number other than 0 or it won't work ;)
0:the flags:
1:horizontal scroll of the map
2:vertical scroll of the map
4:horizontal scroll of the background
8:vertical scroll of the background
use: these are powers of two, it's like 4 bits,1=0001;2=0010,4=0100,8=1000
add the together to get all the scrolls you cant, so 1+2=3 is the map scrolling both ways
1+2+4=7 is map scrolling both ways, the background only scrolling horizontal
1+8=9= the map scrolling hotizontal, the background scrolling vertical
etc...
*/
//sets the levels background images
End
Process level_mask();
Begin
levelmask=load_png(".\sprites\level\mask\testlevelmask.png");
End
//This process is for the player, all code that belongs to him is in this part
Process Player(x,y)
Private
xspeed=3;
yspeed=0;
y_start_acceleration=4;
y_acceleration=0;
int fall;
int falling; //indicate if character is in falling mode or not
jump=0;
int i;
int ii; //you must say: counter to test every pixel of movement of hardness map
int pixel;
int red,blue,green;
int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling
int dir = 1; // -1 when the player faces left, 1 when it faces right
key_x_is_already_pressed = false; //this prevents rapid fire, to shoot 1 every time you
//must press the x key
Begin
//PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't
//look sped up unless you have many detailed frames, you can add as many as you want, just
//be sure to change int Player_graph[X] to the number of sprites you have (0 included, so
//its one number higher than the last Player_graph[X] you have
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=load_png(".\sprites\player\Walk1.png");
Player_graph[2]=load_png(".\sprites\player\Walk1.png");
Player_graph[3]=load_png(".\sprites\player\Walk2.png");
Player_graph[4]=load_png(".\sprites\player\Walk2.png");
Player_graph[5]=load_png(".\sprites\player\Walk2.png");
Player_graph[6]=load_png(".\sprites\player\Walk3.png");
Player_graph[7]=load_png(".\sprites\player\Walk3.png");
Player_graph[8]=load_png(".\sprites\player\Walk3.png");
Player_graph[9]=load_png(".\sprites\player\Walk2.png");
Player_graph[10]=load_png(".\sprites\player\Walk2.png");
Player_graph[11]=load_png(".\sprites\player\Walk2.png");
Player_graph[12]=load_png(".\sprites\player\Stand.png");
Player_graph[13]=load_png(".\sprites\player\Jump.png");
ctype=c_scroll;
Loop
//Player Movement
if (key (_left))
flags = 1;
dir = -1;
ii = 0;
while (ii <4)
pixel = map_get_pixel(0, levelmask, x-16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue<200)
ii = 0;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x-ii;
end
if (key (_right))
flags = 0;
dir = 1;
ii = 0;
while (ii <4)
pixel = map_get_pixel(0, levelmask, x + 16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue<200)
ii = 0;
break;
else
if (player_status!=2 and player_status!=3) player_status=1; end
end
ii = ii + 1;
end
x = x + ii;
end
if (!key(_left) and !key(_right) and player_status==1)
player_status=0;
end
//Shooting
if(key(_x))
if(!key_x_is_already_pressed)//to make sure x isn't already being pressed
if flags == 0;
playerbullet(x, y, dir);
end
if flags == 1;
playerbullet(x, y, dir);
end
end
key_x_is_already_pressed = true;//as long as x is held down, this is true
else
key_x_is_already_pressed = false;//once x is released, this is false
end
// Jumping
if (key (_space))
player_status=2;
falling=true;
pixel = map_get_pixel(0, levelmask, x, y +1 +15);
get_rgb (pixel, & red, & green, & blue);
if (blue<200)
fall =- 20;
end
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue<201)
ii = ii + 1;
falling=false;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
//Ending of jumping and falling status
if (player_status==2 and !key(_space)) player_status=3; end
if (player_status==3 and !falling) player_status=0; end
// Acceleration of gravity
if (ii == 0)
fall = fall + 3;
falling=true;
else
fall = 0;
end
//Player Status
//say(player_status);
switch (player_status)
case 0: graph=Player_graph[12]; end
case 1:
graph=Player_graph[i];
i=(i+1)%12;
end
case 2: graph=Player_graph[13]; end
case 3: graph=Player_graph[13]; end
end
//say("frame");
Frame;
end
end
PROCESS playerbullet(x, y, dir);
private
BULLET_SPEED = 8;
int pixel;
int red,blue,green;
end
begin
graph = load_png(".\sprites\player\bullet.png");
loop
x = x + BULLET_SPEED * dir;
if (collision(TYPE EnemyX))
// do whatever you are supposed to do when you hit an enemy
break;
end
pixel = map_get_pixel(0, levelmask, x, y);
get_rgb (pixel, & red, & green, & blue);
if (blue<201)
break;
end
frame;
end
end
Process EnemyX (x,y)
private
int i;
int ii;
int Xini;
int fall;
int falling;
int pixel;
int red,blue,green;
int inactive;
begin
//animations for the enemy
enemy_x_graph[0]=load_png(".\sprites\enemies\x\x1.png");
enemy_x_graph[1]=load_png(".\sprites\enemies\x\x1.png");
enemy_x_graph[2]=load_png(".\sprites\enemies\x\x1.png");
enemy_x_graph[3]=load_png(".\sprites\enemies\x\x2.png");
enemy_x_graph[4]=load_png(".\sprites\enemies\x\x2.png");
enemy_x_graph[5]=load_png(".\sprites\enemies\x\x2.png");
enemy_x_graph[6]=load_png(".\sprites\enemies\x\x3.png");
enemy_x_graph[7]=load_png(".\sprites\enemies\x\x3.png");
enemy_x_graph[8]=load_png(".\sprites\enemies\x\x3.png");
enemy_x_graph[9]=load_png(".\sprites\enemies\x\x2.png");
enemy_x_graph[10]=load_png(".\sprites\enemies\x\x2.png");
enemy_x_graph[11]=load_png(".\sprites\enemies\x\x2.png");
Xini = x;
loop
if(flags == 0)
ii = 0;
while (ii <3)
pixel = map_get_pixel(0, levelmask, x + 16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue<201)
ii = 0;
flags = 1;
break;
end
ii = ii + 1;
end
x = x + ii;
else
if(flags == 1)
ii = 0;
while (ii <3)
pixel = map_get_pixel(0, levelmask, x-16, y);
get_rgb (pixel, & red, & green, & blue);
if (blue<201)
ii = 0;
flags = 0;
break;
end
ii = ii + 1;
end
x = x-ii;
end
end
i = i +1;
graph = enemy_x_graph [i%12];
falling=true;
if (inactive==0)
falling=true;
end
// Implementation of fall.
ii = fall;
if(ii > 0)
while(ii != 0)
pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15);
get_rgb (pixel, & red, & green, & blue);
if (blue<201)
ii = ii + 1;
falling=false;
break;
end
ii = ii - 1;
end
else
ii = 0;
end
// Move the fall until we can.
y = y + (fall-ii);
// Acceleration of gravity
if (ii == 0)
fall = fall + 3;
falling=true;
else
fall = 0;
end
frame;
end
end
process pellet(x,y)
begin
//loads the fpg
graph=load_png(".\sprites\collectibles\pellet.png");
loop
if(collision(type player))
break;
end
frame;
end
end
Why do you load the same sprites over and over again? It's just a waste of memory.
And you should really use FPGs for animations.
I do it because earlier I actually transitioned everything to .fpg and the game collapsed on itself. then it was .fpg sprites and .png levels, didn't work, .png sprites and .fpg levels, didn't work. besides, the latest fenix (that was ported by SWAT, a noteable russian dreamcast programmer who invented the SDCard slot and Dreamshell, an operating system to use the SDCard slot) version that was ported to the dreamcast actually loads all the .png's just fine (of all 4 game systems released during that generation, the xbox and dreamcast had the exact same amount of video ram).
Quote from: DoctorN on May 29, 2011, 04:06:51 PM
I do it because earlier I actually transitioned everything to .fpg and the game collapsed on itself.
Well then you do like this
[code language="bennu"]
Player_graph[0]=load_png(".\sprites\player\Walk1.png");
Player_graph[1]=Player_graph[0];
Player_graph[2]=Player_graph[0];
//etc...
[/code]
ah that should help. now i have been confused about level size. i remember when the game actually scrolled i could only do a level of 640x480, it wont scroll anymore and i have no idea whats wrong, but is it possible to go bigger?