Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Arrays, images, and loops -_- (https://forums.graalonline.com/forums/showthread.php?t=66533)

excaliber7388 06-07-2006 11:26 PM

Arrays, images, and loops -_-
 
Okay, so I finally have some time to start working on a little game. My problem so far: The ship doesn't show, the comet fragments all show up in the corner of the screen (and as far as I can tell, there's only one of them). I've been staring at this for a while, I can't figure out why it won't work. Help?
PHP Code:

//#CLIENTSIDE
function onKeypressed()
{
if(
strequals(#p(1),D) && strequals(#w,Comet))
{
  if(
this.inuse_comet==0)
  {
    
this.inuse_comet=1;
    
this.screenx_comet=client.compscrnx+2;
    
this.screeny_comet=client.compscrny+2;
    
this.maxscreenx_comet=client.compscrnx+588;
    
this.maxscreeny_comet=client.compscrny+350;
    
this.comet_shipx=this.screenx_comet+294;
    
this.comet_shipy=this.screeny_comet+350;
    
this.level_comet=1;
    
this.levelup_comet=1;
    
settimer(.05);
  }
  else if(
this.inuse_comet==1)
  {
    
this.inuse_comet=0;
    
settimer(0);
    for(
this.i=500this.i<600this.i++)
    {
      
hideimg(this.i);
    }
  }
}
}
function 
onTimeout()
{
  
showimg 500,dr-comet_ship.png,this.comet_shipx,this.comet_shipy;
  
changeimgvis 500,20;
  
freezeplayer .05;
  if(
this.levelup_comet==1)
  {
    for(
this.i=0this.i<this.level_comet*10+3this.i++)
    {
      
this.cometx[this.i]=random(this.screenx_comet,this.maxscreenx_comet-5);
      
this.comety[this.i]=this.screeny_comet+2;
      
this.cometd[this.i]=random(0,3);
    if(
this.cometd[this.i]<1.5)
      {
         
showimg 501+this.i,dr-comet_smallrock.png,this.cometx[this.i],this.comety[this.i];
         
changeimgvis 501+this.i,21;
         
this.comet_img[this.i]="dr-comet_smallrock.png";
         
this.comet_width=20;
      }
    else
      {
        
showimg 501+this.i,dr-comet_bigrock.png,this.cometx[this.i],this.comety[this.i];  
        
changeimgvis 501+this.i,21;
        
this.comet_img[this.i]="dr-comet_bigrock.png";
        
this.comet_width=35;
      }
    }
    
this.levelup_comet=0;
  }
  
//rock movement
  
for(this.i=0this.i<this.level_comet*10+3this.i++)
  {
    
this.comety[this.i]-=.3;
    
showimg 500+this.i,this.comet_img[this.i],this.cometx[this.i],this.comety[this.i];
  }
  
//playermovement
  
if(keydown(1))
  {
    
this.comet_shipx-=.55;
  }
  if(
keydown(3))
  {
    
this.comet_shipx+=.55;
  }
  
  
settimer(.05);



Yen 06-07-2006 11:41 PM

Arrays need to be defined.
Stop mixing GS2 with GS1.

array = new[size]; in GS2
setarray variable,size; in GS1

excaliber7388 06-07-2006 11:53 PM

Well, that does solve the array problem, it's making more imgs now. But they still all form in the corner of the screen, and the ship img doesn't even appear

Yen 06-08-2006 12:04 AM

Make sure it's not a problem with the variables. (client. ones)

excaliber7388 06-08-2006 12:28 AM

the client. variables are fine, I use them for multiple scripts

Yen 06-08-2006 12:32 AM

I'm probably overlooking something, but try lowering your image layers.

excaliber7388 06-08-2006 12:37 AM

I've ran images above that, 25 before. It's so high to allow lots of layering, but I could lower them. I doubt this would change much though

Warcaptain 06-08-2006 02:55 AM

stop using strequals??

if (params[1]=="d")

excaliber7388 06-08-2006 04:27 AM

Quote:

Originally Posted by Warcaptain
stop using strequals??

if (params[1]=="d")

You can mix the two engines, and it will work, however thanks, I screded it up the first time I tried that in GS2 I guess :\
I don't think that's the only problem :(

Skyld 06-08-2006 11:31 AM

Quote:

Originally Posted by excaliber7388
You can mix the two engines, and it will work, however thanks, I screded it up the first time I tried that in GS2 I guess :\
I don't think that's the only problem :(

Just because it works does not make it good practice. In fact, mixing the two engines is very bad practice; it makes code very untidy and it is not as efficient.

excaliber7388 06-08-2006 04:23 PM

Quote:

Originally Posted by Skyld
Just because it works does not make it good practice. In fact, mixing the two engines is very bad practice; it makes code very untidy and it is not as efficient.

I only mix it when I'm not sure how to gs2 it, the script would still work, so that can't be the reason it doesn't work. But yeah, I hate mixing them XD


All times are GMT +2. The time now is 07:53 AM.

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