Code Structure


Imerion

Member
Joined
Feb 24, 2005
Messages
218
Since I am just learning Fenix I seem to be unable to get the structure right. I am used to other languages so I guess Im having a hard time to adapt. Anyway, in this piece of code, the car should be rotatable with left and right and small clouds should move across the level. However, nothing of this happens. Any idea why? Any help would be appreciated!

Code:
program car;

global

gfx;

rot=1;

private

begin

set_mode(640,480,8);


gfx=LOAD_FPG("C:/dev/fenix/bkg.fpg");

put_screen(gfx,1);


car();

cloud1();


while (not key(_space))

If(key(_left))

   rot +=1;

End

If(key(_right))

   rot -=1;

End

   frame;

end

end





process car();

private

begin

X=90;

Y=40;

If(rot=1)

GRAPH= 2;

End

If(rot=2)

GRAPH= 3;

End

If(rot=3)

GRAPH= 4;

End

If(rot=4)

GRAPH= 5;

End

If(rot=5)

GRAPH= 6;

End

If(rot=6)

GRAPH= 7;

End

If(rot=7)

GRAPH= 8;

End

If(rot=8)

GRAPH= 9;

End

If(rot=-1)

   rot=8;

End

If(rot=9)

   rot=1;

End

loop

  frame;

end

end



process cloud1()

private

begin

X=290;

Y+=1;

If(Y=600)

   Y=1;

End

GRAPH= 11;

end
 
Code:
program car;

global
   gfx;
   rot=1;

begin
   set_mode(640,480,8);
   gfx=LOAD_FPG("C:/dev/fenix/bkg.fpg");
   put_screen(gfx,1);
   car();
   cloud1();
end

process car();

begin
   X=90;
   Y=40;
   loop;
      If(key(_left));
         rot +=1;
      End
      If(key(_right));
         rot -=1;
      End
      
      If(rot==-1);
         rot=8;
      End
      If(rot==9);
         rot=1;
      End
      
      graph=rot+1;      
      
      frame;
   
   end
end



process cloud1();

begin
   X=290;
   Y+=1;
   If(Y==600);
      Y=1;
   End
   GRAPH= 11;
end

Try this one, hope it works fine.
 
Code:
program car;

 global
   gfx;
   rot=1;

 begin
   set_mode(640,480,8);
   gfx=LOAD_FPG("C:/dev/fenix/bkg.fpg");
   put_screen(gfx,1);
   car();
   cloud1();
  end


process car();
 begin
   X=90;
   Y=40;
   loop;
     If(key(_left));
       rot +=1;
      end:

     If(key(_right));
       rot -=1;
      end;
      
     If(rot==-1);
       rot=8;
      End

     If(rot==9);
       rot=1;
      End
      
     graph=rot+1;            
     frame;   
    end
  end


process cloud1();
 begin
   X=290;
   Y+=1;
   If(Y==600);
     Y=1;
    End
   GRAPH=11;
  end

Mine would look like this :)
 
Thanks a lot! Ill study this closely! Its good to have the structure correct from the beginning.
 
Back
Top