View Single Post
  #1  
Old 07-15-2009, 04:44 AM
Ronnie Ronnie is offline
Registered User
Join Date: Jun 2008
Location: Nj, USA
Posts: 48
Ronnie is on a distinguished road
Send a message via AIM to Ronnie
Odd Scripting error.

I am making a kinda version of snake, but instead of growing longer I have the object move faster , so this is where the problem comes in, on the timeout i have it move the gui control based on the direction, but if the direction is going ether right or down it doesn't work , and I really cant find out why. Thanks in advance.

PHP Code:
function onPlayerTouchsme() {
  new 
GuiWindowCtrl"ron_game" ) {
   
useownprofile true;
   
profile "teststyle";
   
190;
   
140;
   
width 500;
   
height 440;
   
text "Catch That Greasy Chicken! !";
   
destroyonhide true;
   
canmaximize false;
   
canminimize false;
   
canresize false;
   
canclose true;

  new 
GuiScrollCtrl"ron_field" ) {
  
24;
  
35;
  
width 450;
  
height 300;
  
hScrollBar "dynamic";
  
vScrollBar "alwaysOff";

  new 
GuiShowImgCtrl"ron_dot" ) {
  
random(1,248);
  
random(1,190);
  
width 60;
  
height 60;
  
ani "cry";
  
actor.head "head180.png";
  
actor.body "lgarmor-body100.png";
  }

  new 
GuiShowImgCtrl"ron_plr" ) {
   
ron_field.width/2;
   
ron_field.height/2;
   
width 60;
   
height 60;
   
ani "walk";
   
actor.head player.headimg;
   
actor.body player.bodyimg;
   }



  }

   new 
GuiButtonCtrl"ron_button0" ) {
   
30;
   
350;
   
width 215;
   
height 30;
   
text "Start Game!";
   }

   new 
GuiButtonCtrl"ron_button1" ) {
   
255;
   
350;
   
width 215;
   
height 30;
   
text "End Game!";
   }



 new 
GuiButtonCtrl"ron_button2" ) {
   
140;
   
390;
   
width 215;
   
height 30;
   
text "Controls & Help!";
   }


 }
}

function 
ron_button0.onAction() {
 if ( 
this.gamestatus != "on" ) {
  
//disabledefmovement();
  
this.gamestatus "on";
  
this.level 1;
  
onTimeout();
  
ron_dot.random, ( ron_field.width 20 ) ) ;
  
ron_dot.random, ( ron_field.height 20) ) ;
  
ron_game.pushtoback();
  }
 }

function 
onTimeout() {
  
this.speed = ( ( this.level .25 ) + .15 );

/*Checking for hitting of the dot.
  if ( ( (ron_plr.x - ron_dot.x) < 1 ) || ( (ron_plr.x + ron_dot.x) < 1 ) ) {
   if ( (ron_plr.x - ron_dot.x) < 1) || ( (ron_plr.x + ron_dot.x) < 1) ) ) {
   this.score += ( this.level * 2.5 );
   this.level += 1;
   ron_dot.x = int[random( 1 , 248 )];
   ron_dot.y = int[random( 1 , 190 )];
   }
  }
 */

  
ron_game.text "Catch that Greasy Chicken!               Score : " this.score;
  if ( 
ron_game.visible != true ) {
   
this.gamestatus "off";
   }

  if ( 
this.gamestatus == "on" ) {
   switch ( 
this.direction ) {

    case 
1:
    
ron_plr.dir 1;
    
ron_plr.-= this.speed;
    break;

    case 
3:
    
ron_plr.dir 2;
    
ron_plr.+= this.speed;
    break;

    case 
4:
    
ron_plr.dir 3;
    
ron_plr.+= this.speed;
    break;

    case 
2:
    
ron_plr.dir 0;
    
ron_plr.-= this.speed;
    break;

   }
  }

  
setTimer0.05 );
 }

function 
onKeyPressedkeycodekeynamescancode) {
  switch( 
keycode ) {
  case 
"37":
  
this.direction 1;
  break;

  case 
"38":
  
this.direction 2;
  break;

  case 
"39":
  
this.direction 4;
  break;

  case 
"40":
  
this.direction 3;
  break;

  }
 } 
Reply With Quote