PDA

View Full Version : need a bit help! ;)



Sonic-NKT
January 23rd, 2005, 16:05
Hi,
i just started to learn fenix and im working a bit on a Zelda like game..
i do this with help of a tutorial.

i use this code to move the charakter


if (key(_right) and not key(_up) and not key(_down))
x=x+2; angle=0;
if (graph<=2 or graph>=7) graph=2; end;
graph++; flags=0; angle=0;
end

now the problem is, that if you dont press the button anymore, the last sprite which was drawn stays on the screen and that looks sometimes a bit strange..
so i want to add a bit more code to this..
graph = 1 should be drawn after moving...
how i can do this?

pauljake
January 24th, 2005, 17:41
Well, I don't know perfectly what are you asking, because the code you paste is very abstract... but I've made something that can help you


program zelda_clone;
Begin
Set_title("Zelda Clone");
Full_screen = FALSE;
Graph_mode = mode_16bits;
Set_mode (m640x480);
load_fpg("myfpg.fpg");
chara();
end

PROCESS chara()
// graph=1 when character is standing, graph from 2 to 4 when is walking
// graphs originally drawn with character head looking up

PRIVATE walking;

BEGIN
x=320;
y=240;
graph=1;
LOOP
IF (key(_right))
x=x+2;
angle=270000;
walking=1;
END
IF (key(_left))
x=x-2;
angle=90000;
walking=1;
END
IF (key(_up))
y=y-2;
angle=0;
walking=1;
END
IF (key(_down))
y=y+2;
angle=180000;
walking=1;
END
IF (NOT (key(_right)) AND NOT (key(_up)) AND NOT (key(_down)) AND NOT (key(_left)))
walking=0;
END
If (walking==1)
graph=graph+1;
END
IF (walking==1 AND graph==5)
graph=2;
END
IF (walking==0)
graph=1;
END
IF (key(_esc))
exit("",0);
END
frame;
END
END


Hope this can help, I think that there is another easiest way to make this, but I'm asleep (I retourned from vacation today, have to return early...)