Monday, October 02, 2006

Coding the Main Character

As for level 1, lets start with the code for the main character:

if (key=VK_RIGHT) and (Blocked=false) then begin // Key Right
if PosChar=3 then begin PosChar:=4; ImageHero4.visible:=true; ImageHero3.visible:=false; end;
if PosChar=2 then begin PosChar:=3; ImageHero3.visible:=true; ImageHero2.visible:=false; end;
if PosChar=1 then begin PosChar:=2; ImageHero2.visible:=true; ImageHero1.visible:=false; end;
end;
if (key=VK_LEFT) and (Blocked=false) then begin // Key Left
if PosChar=2 then begin PosChar:=1; ImageHero1.visible:=true; ImageHero2.visible:=false; end;
if PosChar=3 then begin PosChar:=2; ImageHero2.visible:=true; ImageHero3.visible:=false; end;
if PosChar=4 then begin PosChar:=3; ImageHero3.visible:=true; ImageHero4.visible:=false; end;
end;
if (key=VK_SPACE) and (Blocked=false) then begin // Key Space - Firing bullet
if BulletHero=0 then begin
BulletHero:=1;
if PosChar=1 then begin BulletAHeroPos:=1; PlaySound(pfPlay); end;
if PosChar=2 then begin BulletBHeroPos:=1; PlaySound(pfPlay); end;
if PosChar=3 then begin BulletCHeroPos:=1; PlaySound(pfPlay); end;
if PosChar=4 then begin BulletDHeroPos:=1; PlaySound(pfPlay); end;
end;
end;


No comments: