Another Structure Problem


Imerion

Member
Joined
Feb 24, 2005
Messages
218
I added some kind of very simple acceleration to my racing-game (timing will come later. For the moment it will reach full speed immediately :) ). Anyway, the code does not wor correctly. Nothing happens when I press up. I am pretty certain it has to do with the structure of the code. Could anyone tell me how it should be? Any help will be highly appreciated!

Code:
program car;

global
  gfx;
  rot=1;
  sp;


begin

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


process car();

begin
  X=190;
  Y=120;
  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;


    If(key(_up));
      sp +=1;
     end:
     
    frame;  
   end
 end


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

 if(sp>0);
   sp -=1;
 end
 
 if(rot==1);
    X +=sp;
 end
 
 if(rot==2);
    X +=sp;
    Y +=sp;
 end
 
 if(rot==3);
    Y +=sp;
 end
 
 if(rot==4);
    X -=sp;
    Y +=sp;
 end
 
 if(rot==5);
    X -=sp;
 end

 if(rot==6);
    X -=sp;
    Y -=sp;
 end

 if(rot==7);
    Y -=sp;
 end

 if(rot==8);
    X +=sp;
    Y -=sp;
 end
 
 end
 
Quick answer:
I think that you need to put a LOOP comand in process spd() because now only is checked one time.

Another way you can try is to extract the "spd();" line from the main process and put it inside the LOOP of the CAR() process.


Byes


PD: Sorry for my english.
 
Back
Top