Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.