My new NXT game- After Dark, in grayscale

Discussion specific to projects ideas and support.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: My new game- After Dark

Post by HaWe »

and please where's the code?
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new game- After Dark

Post by nxtboyiii »

Umm.... I can probably give you the code later today.
BE WARNED: The code is verrrrrrrrrrrrrrryyyyyyyyyy messy. :oops:
Thanks, and have a nice day,
nxtboy III

programnxt.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: My new NXT game- After Dark, in grayscale

Post by HaWe »

maybe you wish to polish it up before publishing it (e.g. exchanging gibberish by expressive keywords and inserting correct white space / tabs, and MAYBE write some comments...?)
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new NXT game- After Dark, in grayscale

Post by nxtboyiii »

I'll just post the .rics and the executable.
Here ya go.
Just drag all the files to the NXT.
For best grayscale performance, don't use the NXT Screen utility in Bricxcc while playing the game.
Attachments
After Dark.zip
My game, After Dark
(17.43 KiB) Downloaded 369 times
Thanks, and have a nice day,
nxtboy III

programnxt.com
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new NXT game- After Dark, in grayscale

Post by nxtboyiii »

So what do you think of it?
Thanks, and have a nice day,
nxtboy III

programnxt.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: My new NXT game- After Dark, in grayscale

Post by HaWe »

the code is what I was curious of
(BTW why didn't you delete your double post?)
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new NXT game- After Dark, in grayscale

Post by nxtboyiii »

But what do you think of the game?
Do you like the grayscale?
Thanks, and have a nice day,
nxtboy III

programnxt.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: My new NXT game- After Dark, in grayscale

Post by HaWe »

yes, it's really remarkable!
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new NXT game- After Dark, in grayscale

Post by nxtboyiii »

Well since you already have all the .rics, here's the code:

Code: Select all

int mapx,mapy;
float fmapx,fmapy;
int xadd,yadd;
int xadd2,yadd2;
byte map[25][5];
byte width=25;
byte height=5;
int x,y;
int paddx,paddy;
int xpp,ypp;
int xd,yd;
bool executeMe;
int xdd,ydd;
int xdd2,ydd2;
bool bAddP;
byte NUMOFENEMIES=6;
byte weapon_in_use;
bool attack;
bool DrawParticles;
float particlex[10];
float particley[10];
float particleax[10];
float particleay[10];
int particlepower;
int particleangle;
int particle_timer;
bool canattack;
bool deademy;
byte particle_count;
byte gib_var[1];
unsigned long t0z;
int life;
byte wpn_width[8];
string weapon_filename;
bool paused,shop;
int sely;
byte wpn_cost[8];
int money=300;
int bulletx[6];
int bullety[6];
bool active_bullets[6];
int befbulletx[6];
int bul;
int bulletspeed;
bool bDisplayWhiteOut;
int zomspeed=2;
int zomlife=10;

 DrawGraphicType plyr;

struct enemy
{
 int x;
 int y;
 char life;
 byte var1;
 bool zom_move;
 byte zom_move_timer;
 byte var2;
};
enemy emy[NUMOFENEMIES];

void EnemyInit(byte index, byte enemytype, byte enmapx, byte enmapy, char life)
{
// emy[index].enemytype=enemytype;
// emy[index].mapx=enmapx;
// emy[index].mapy=enmapy;
 emy[index].life=life;
 emy[index].x=enmapx*16;
 emy[index].y=enmapy*16;
// emy[index].fmapx=enmapx;
// emy[index].fmapy=enmapy;
// emy[index].xpp=enmapx*16;
// emy[index].ypp=enmapy*16;
}

#define bLeft ButtonPressed(BTNLEFT,0)
#define bRight ButtonPressed(BTNRIGHT,0)
#define bCenter ButtonPressed(BTNCENTER,0)
#define bExit ButtonPressed(BTNEXIT,0)

#define RIGHT 0
#define WALKRIGHT 27
#define LEFT 54
#define WALKLEFT 81

#define GRASS 0
#define QUESTION 1
#define SKELIBOTTOM 2
#define SKELITOP 5
#define GRAVESTONE 73
#define DARK 72
#define AIR 74
#define GOOMBATILE 60
#define TORCH 62
#define FIRE 132
#define STONE 4
#define TNT 3

#define ZOMBIE 0

#define SWORD 0
#define LONGSWORD 1
#define STAFF 2
#define PISTOL 3
#define MACHINEGUN 4


void PlaceSkeletonStatue(byte _x, byte _y)
{
 map[_x][_y]=SKELIBOTTOM;
 map[_x][_y+1]=SKELITOP;
}

task tiles()
{
 int cen,den;
 byte var[1];
 DrawGraphicType gargs;
 DrawGraphicType enemygraphic;
 ArrayInit(gargs.Variables,0,35);
 ArrayInit(enemygraphic.Variables,0,2);
  ArrayInit(plyr.Variables,0,2);
  plyr.Filename="man.ric";
 unsigned long t0;
 byte mapt[35]; //7x5 + setting
 byte yt;
 byte v;
 byte animation_loop;
 string enemyfilename;
 byte temp_enemy_var[1];
 byte weapon_var[2];
 char weapon_x_add;
 bool canattack;
 bool canattack2;
 bool pressed;
 bool shoot;
 unsigned long endtime;
 byte menuvar[1];
 byte healthvar[1];
 string fn;
 enemygraphic.Filename="emy_zombie.ric";
 enemy tdemy;
 while(1)
 {
   xadd2=xadd;
   yadd2=yadd;
   ydd2=ydd;
   xdd2=xdd;
  cen=floor(xadd2/-16)+7;
  den=floor(yadd2/-16)+5;
  yt=0;
   if(!paused)
   {
    for(int cc=floor(xadd2/-16); cc < cen; cc++)
  {
   for(int dd=floor(yadd2/-16); dd < den; dd++)
   {
    v=map[cc][dd];
/*    if(animation_loop == 1)
    {
    if(v >= 132)
    {
           if(frac(v/2.0) == 0) //If v is even
      {
       v++;
      }
      else                 //If v is odd
      {
       v--;
      }
      map[cc][dd]=v;
    }
    else if(v >= 60)
    {
     if(v <= 71)
     {
      if(frac(v/2.0) == 0) //If v is even
      {
       v++;
      }
      else                 //If v is odd
      {
       v--;
      }
      map[cc][dd]=v;
     }
    }
    }  */
    mapt[yt]=v;
    yt++;
   }
   animation_loop++;
   if(animation_loop == 3)
    animation_loop=0;
  }
  }
  if(bRight)
  {
   if(plyr.Variables[1] == RIGHT)
    plyr.Variables[1]=WALKRIGHT;
    else
    plyr.Variables[1]=RIGHT;
     weapon_x_add=15;
     weapon_var[1]=0;
  }
   else if(bLeft)
  {
   if(plyr.Variables[1] == LEFT)
    plyr.Variables[1]=WALKLEFT;
    else
    plyr.Variables[1]=LEFT;
     weapon_x_add=(wpn_width[weapon_in_use]-1)*-1;
     weapon_var[1]=8;
  }
  else
  {
    if(plyr.Variables[1] == WALKLEFT)
     plyr.Variables[1]=LEFT;
    else if(plyr.Variables[1] == WALKRIGHT)
     plyr.Variables[1]=RIGHT;
  }
  attack=0;
  if(weapon_x_add == 18)
  weapon_x_add=15;
  else if(weapon_x_add == -10)
  weapon_x_add=-7;
  if(SENSOR_1)
  {
    pressed=1;
    if(weapon_in_use == MACHINEGUN)
    {
     shoot=1;
    }
  }
      if(weapon_in_use == PISTOL)
    {
     if(canattack)
     {
      canattack=0;
      shoot=1;
    }
    }
    else if(canattack)
    {
    canattack=0;
    attack=1;
    if(plyr.Variables[1] == RIGHT || plyr.Variables[1] == WALKRIGHT)
    weapon_x_add=18;
    else if(plyr.Variables[1] == LEFT || plyr.Variables[1] == WALKLEFT)
    weapon_x_add=-10;
    }
    if(shoot)
    {
     shoot=0;
          active_bullets[bul]=1;
     bulletx[bul]=x+16+wpn_width[weapon_in_use];
     befbulletx[bul]=x+16+wpn_width[weapon_in_use];
         if(plyr.Variables[1] == RIGHT || plyr.Variables[1] == WALKRIGHT)
         {
    bulletx[bul]=x+16+wpn_width[weapon_in_use];
     befbulletx[bul]=x+16+wpn_width[weapon_in_use];
     }
    else if(plyr.Variables[1] == LEFT || plyr.Variables[1] == WALKLEFT)
    {
     bulletx[bul]=x-wpn_width[weapon_in_use];
     befbulletx[bul]=x-wpn_width[weapon_in_use];
    }
     bullety[bul]=y+11+Random(3);
     if(weapon_in_use == MACHINEGUN)
     {
     if(bul < 6)
     bul++;
     else
     bul=0;
     }
          if(weapon_in_use == MACHINEGUN)
     {
         if(plyr.Variables[1] == RIGHT || plyr.Variables[1] == WALKRIGHT)
    bulletspeed=6;
    else if(plyr.Variables[1] == LEFT || plyr.Variables[1] == WALKLEFT)
    bulletspeed=-6;
    }
    else
    {
              if(plyr.Variables[1] == RIGHT || plyr.Variables[1] == WALKRIGHT)
    bulletspeed=15;
    else if(plyr.Variables[1] == LEFT || plyr.Variables[1] == WALKLEFT)
    bulletspeed=-15;
    }
    }
  Wait(17-(CurrentTick()-t0));
  SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  plyr.Location.X=x;
  plyr.Location.Y=y;
  gargs.Filename="pic1.ric";
    gargs.Variables=mapt;
    gargs.Location.X=xdd2;
    gargs.Location.Y=ydd2;
    SysDrawGraphic(gargs);
     for(int c=0; c < NUMOFENEMIES; c++)
   {
    if(emy[c].life > 0)
    {
     if(emy[c].x <= 96 && emy[c] >= -15)
     {
      tdemy=emy[c];
/*     switch(tdemy.enemytype)
     {
      case ZOMBIE:
      enemygraphic.Filename="emy_zombie.ric";
      break;
     }*/

       if(animation_loop == 1)
  {
  if(tdemy.var2 == 0 || tdemy.var2 == 48)
   tdemy.var2+=24;
   else
   tdemy.var2-=24;
   }
     enemygraphic.Variables[1]=tdemy.var2;
     enemygraphic.Variables[0]=tdemy.var1;
     enemygraphic.Location.X=tdemy.x;
     enemygraphic.Location.Y=tdemy.y;
     SysDrawGraphic(enemygraphic);
     tdemy.var1+=16;
     emy[c]=tdemy;
    }
    }
   }
       plyr.Variables[0]=0;
  SysDrawGraphic(plyr);
  weapon_var[0]=0;
   GraphicOutEx(x+weapon_x_add,y+10,weapon_filename,weapon_var);
   if(DrawParticles)
   {
       particle_timer++;
       if(!deademy)
       {
        if(particle_timer >= 10)
        {
         DrawParticles=0;
        }
       }
       else if(particle_timer >= 20)
       {
        DrawParticles=0;
        deademy=0;
       }
      for(int c=0; c < particle_count; c++)
  {
/*   particlex[c]+=particleax[c];
   particley[c]+=particleay[c];
   particlepower--;
   if(particlepower <= 0)
   {
    particleay[c]-=0.2;
   }
   particley[c]-=0.2;*/
         if(c == 13)
   {
    fn="zomhead.ric";
   }
   else
   fn="gib.ric";
   GraphicOutEx(particlex[c],particley[c],fn,gib_var);
  }
   }
   if(paused)
   {
    menuvar[0]=0;
    GraphicOutEx(16,0,"menu_back.ric",menuvar);
    if(!shop)
    {
     TextOut(25,LCD_LINE1,"Unpause");
     TextOut(25,LCD_LINE2,"Shop");
    }
    else
    {
     TextOut(25,LCD_LINE1,"Exit Shop");
     TextOut(25,LCD_LINE2,"Long Sword");
     TextOut(25,LCD_LINE3,"Staff");
     TextOut(25,LCD_LINE4,"Pistol");
     TextOut(25,LCD_LINE5,"Mach-Gun");
     TextOut(25,LCD_LINE8,StrCat("Cost$",NumToStr(wpn_cost[sely/-8+7])," $", NumToStr(money)));
    }
    RectOut(23,sely,54,8,DRAW_OPT_FILL_SHAPE | DRAW_OPT_LOGICAL_XOR);
   }
   for(int c=0; c < 6; c++)
   {
    if(active_bullets[c])
    {
     LineOut(bulletx[c],bullety[c],bulletx[c]+3,bullety[c],DRAW_OPT_INVERT);
    }
   }
/*     if(bDisplayWhiteOut)      //Display "White out" effect when bDisplayWhiteOut == true, which is when the character is hurt
     {
      bDisplayWhiteOut=false;
      ClearScreen();
     }*/
        healthvar[0]=0;                             //Sets up variable for healthvar so it can be grayscale
   GraphicOutEx(0,62,"health-back.ric",healthvar); //Draw the health bar
     RectOut(0,62,life,1,DRAW_OPT_LOGICAL_XOR);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
      if(pressed)
  {
  if(!SENSOR_1)
  {
     pressed=0;
   canattack=1;
  }
  }
    SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
     //   ClearScreen();
    gargs.Filename="pic2.ric";
    gargs.Location.X=xdd2;
    gargs.Location.Y=ydd2;
    SysDrawGraphic(gargs);
       for(int c=0; c < NUMOFENEMIES; c++)
   {
    if(emy[c].life > 0)
    {
         if(emy[c].x <= 96 && emy[c] >= -15)
     {
     tdemy=emy[c];
/*     switch(tdemy.enemytype)
     {
      case ZOMBIE:
      enemygraphic.Filename="emy_zombie.ric";
      break;
     }*/

            if(animation_loop == 1)
  {
  if(tdemy.var2 == 0 || tdemy.var2 == 48)
   tdemy.var2+=24;
   else
   tdemy.var2-=24;
   }
     enemygraphic.Variables[1]=tdemy.var2;
     enemygraphic.Variables[0]=tdemy.var1;
     enemygraphic.Location.X=tdemy.x;
     enemygraphic.Location.Y=tdemy.y;
     SysDrawGraphic(enemygraphic);
     tdemy.var1+=16;
     emy[c]=tdemy;
    }
    }
   }
        plyr.Variables[0]=16;
  SysDrawGraphic(plyr);
  weapon_var[0]=wpn_width[weapon_in_use];
   GraphicOutEx(x+weapon_x_add,y+10,weapon_filename,weapon_var);
      if(DrawParticles)
   {
      for(int c=0; c < particle_count; c++)
  {
   particlex[c]+=particleax[c];
   particley[c]+=particleay[c];
   particlepower--;
   if(particlepower <= 0)
   {
    particleay[c]-=0.2;
   }
   particley[c]-=0.2;
      if(c == 13)
   {
    fn="zomhead.ric";
   }
   else
   fn="gib.ric";
   GraphicOutEx(particlex[c],particley[c],fn,gib_var);
  }
   }
   if(paused)
   {
    menuvar[0]=68;
    GraphicOutEx(16,0,"menu_back.ric",menuvar);
    if(!shop)
    {
     TextOut(25,LCD_LINE1,"Unpause");
     TextOut(25,LCD_LINE2,"Shop");
    }
    else
    {
     TextOut(25,LCD_LINE1,"Exit Shop");
     TextOut(25,LCD_LINE2,"Long Sword");
     TextOut(25,LCD_LINE3,"Staff");
     TextOut(25,LCD_LINE4,"Pistol");
     TextOut(25,LCD_LINE5,"Mach-Gun");
     TextOut(25,LCD_LINE8,StrCat("Cost$",NumToStr(wpn_cost[sely/-8+7])," $", NumToStr(money)));
    }
    RectOut(23,sely,54,8,DRAW_OPT_FILL_SHAPE | DRAW_OPT_LOGICAL_XOR);
   }
      for(int c=0; c < 6; c++)
   {
    if(active_bullets[c])
    {
     LineOut(bulletx[c],bullety[c],bulletx[c]+3,bullety[c],DRAW_OPT_INVERT);
    }
   }
   healthvar[0]=40;
   GraphicOutEx(0,62,"health-back.ric",healthvar);
   RectOut(0,62,life,1,DRAW_OPT_LOGICAL_XOR); //Draw the health bar
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
  if(SENSOR_1)
  {
   pressed=1;
  }
      SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
//  ClearScreen();
  gargs.Filename="pic3.ric";
    gargs.Location.X=xdd2;
    gargs.Location.Y=ydd2;
    SysDrawGraphic(gargs);
       for(int c=0; c < NUMOFENEMIES; c++)
   {
    if(emy[c].life > 0)
    {
         if(emy[c].x <= 96 && emy[c] >= -15)
     {
     tdemy=emy[c];
/*     switch(tdemy.enemytype)
     {
      case ZOMBIE:
      enemygraphic.Filename="emy_zombie.ric";
      break;
     }*/

            if(animation_loop == 1)
  {
  if(tdemy.var2 == 0 || tdemy.var2 == 48)
   tdemy.var2+=24;
   else
   tdemy.var2-=24;
   }
     enemygraphic.Variables[1]=tdemy.var2;
     enemygraphic.Variables[0]=tdemy.var1;
     enemygraphic.Location.X=tdemy.x;
     enemygraphic.Location.Y=tdemy.y;
     SysDrawGraphic(enemygraphic);
      tdemy.var1=0;
      emy[c]=tdemy;
    }
    }
   }
       plyr.Variables[0]=32;
  SysDrawGraphic(plyr);
  weapon_var[0]=wpn_width[weapon_in_use]*2;
   GraphicOutEx(x+weapon_x_add,y+10,weapon_filename,weapon_var);
      if(DrawParticles)
   {
      for(int c=0; c < particle_count; c++)
  {
   particlex[c]+=particleax[c];
   particley[c]+=particleay[c];
   particlepower--;
   if(particlepower <= 0)
   {
    particleay[c]-=0.2;
   }
   particley[c]-=0.2;
      if(c == 13)
   {
    fn="zomhead.ric";
   }
   else
   fn="gib.ric";
   GraphicOutEx(particlex[c],particley[c],fn,gib_var);
  }
   }
   if(paused)
   {
    menuvar[0]=136;
    GraphicOutEx(16,0,"menu_back.ric",menuvar);
    if(!shop)
    {
     TextOut(25,LCD_LINE1,"Unpause");
     TextOut(25,LCD_LINE2,"Shop");
    }
    else
    {
     TextOut(25,LCD_LINE1,"Exit Shop");
     TextOut(25,LCD_LINE2,"Long Sword");
     TextOut(25,LCD_LINE3,"Staff");
     TextOut(25,LCD_LINE4,"Pistol");
     TextOut(25,LCD_LINE5,"Mach-Gun");
     TextOut(25,LCD_LINE8,StrCat("Cost$",NumToStr(wpn_cost[sely/-8+7])," $", NumToStr(money)));
    }
    RectOut(23,sely,54,8,DRAW_OPT_FILL_SHAPE | DRAW_OPT_LOGICAL_XOR);
   }
      for(int c=0; c < 6; c++)
   {
    if(active_bullets[c])
    {
     LineOut(bulletx[c],bullety[c],bulletx[c]+3,bullety[c],DRAW_OPT_INVERT);
    }
   }
      healthvar[0]=80;
   GraphicOutEx(0,62,"health-back.ric",healthvar);
  RectOut(0,62,life,1,DRAW_OPT_LOGICAL_XOR); //Draw the health bar
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  t0=CurrentTick();
  if(weapon_in_use != PISTOL)
  {
  if(attack)
  {
   if(!SENSOR_1)
   canattack2=1;
   else
   canattack2=0;
  }
  else
  canattack2=1;
  }
/*    if(pressed)
  {
   pressed=0;
  if(!SENSOR_1)
  {
   canattack=1;
  }
  else
  canattack=0;
  }*/
 }
}


task engine()
{
 Wait(300);
 char starthitcheck, endhitcheck;
 enemy temy;
 while(1)
 {
            paddx=fmapx == floor(fmapx)?0:1;
//  mapy=floor(fmapy);
  paddy=fmapy == floor(fmapy)?0:1;
      //startleft
  if(bLeft)
  {
   executeMe=false;
      if(map[mapx-1][mapy] >= DARK)
   {
    if(map[mapx-1][mapy+paddy] >= DARK)
    {
     executeMe=true;
    }
   }
   else if(fmapx > floor(fmapx))
   executeMe=true;
    if(executeMe)
    {
     xpp-=4;
     fmapx=xpp/16;
     if(xadd == 0)
     {
      xd=0;
      x-=4;
     }
     else if(x == 32)
     {
      xd+=4;
     }
     else if(x > 32)
     {
      xd=0;
      x-=4;
     }
    }
  }
  //finishleft
  mapx=floor(fmapx);
        //startright
  if(bRight)
  {
      executeMe=false;
      if(map[mapx+1][mapy] >= DARK)
   {
    if(map[mapx+1][mapy+paddy] >= DARK)
    {
     executeMe=true;
    }
   }
    if(executeMe)
    {
     xpp+=4;
     fmapx=xpp/16;
     if(xadd/-16.0 < width-7 && x == 32)
     {
      xd-=4;
     }
     else
     {
      xd=0;
      x+=4;
     }
    }
  }
  //finishright
     mapx=floor(fmapx);
     paddx=fmapx == floor(fmapx)?0:1;
  mapx=floor(fmapx);
     xadd+=xd;
   yadd+=yd;
   xdd+=xd;
   ydd+=yd;
         if(frac(xdd/-16.0) == 0)
  {
   xdd=0;
  }
  else if(xdd > 0)
  {
   xdd-=16;
  }
    if(frac(ydd/-16.0) == 0)
  {
   ydd=0;
  }
    else if(ydd > 0)
  {
   ydd-=16;
  }
  if(bCenter)
  {
   until(!bCenter);
   paused=true;
   sely=LCD_LINE1;
   until(bCenter && sely == LCD_LINE1 && !shop)
   {
    if(bLeft && sely != LCD_LINE1)
    {
     until(!bLeft);
     sely+=8;
    }
    if(bRight)
    {
     until(!bRight);
     sely-=8;
    }
    if(bCenter)
    {
     until(!bCenter);
     if(!shop)
     {
      if(sely == LCD_LINE2)
      {
       shop=1;
      }
            if(sely == LCD_LINE1)
      {
       goto outofpause;
      }
     }
     else
     {
      if(sely == LCD_LINE1)
      {
       shop=0;
      }
      if(sely <= LCD_LINE2)
      {
       if(money >= wpn_cost[sely/-8+7])
       {
        weapon_in_use=sely/-8+7;
        money-=wpn_cost[sely/-8+7];
        PlayToneEx(600,200,1,0);
        Wait(200);
        PlayToneEx(800,200,1,0);
        Wait(200);
             switch(weapon_in_use)
  {
   case SWORD:
   weapon_filename="wpn_sword.ric";
   break;
   case LONGSWORD:
   weapon_filename="wpn_lngsword.ric";
   break;
   case STAFF:
   weapon_filename="wpn_staff.ric";
   break;
   case PISTOL:
   weapon_filename="wpn_pistol.ric";
   break;
      case MACHINEGUN:
   weapon_filename="wpn_mgun.ric";
   break;
  }
       }
       else
       {
        PlayToneEx(600,200,1,0);
        Wait(200);
        PlayToneEx(400,200,1,0);
        Wait(200);
       }
      }
     }
    }
   }
   outofpause:
           PlayToneEx(600,200,1,0);
        Wait(200);
        PlayToneEx(400,200,1,0);
        Wait(200);
   until(!bCenter);
   paused=false;
  }
  t0z=CurrentTick();
  for(int c=0; c < 6; c++)
  {
   if(active_bullets[c])
   {
    bulletx[c]+=bulletspeed;
    if(bulletspeed >= 1)
    {
     if(bulletx[c] >= 120)
     {
      active_bullets[c]=0;
     }
    }
    else
    {
     if(bulletx[c] <= -40)
     {
      active_bullets[c]=0;
     }
    }
   }
  }
   for(int c=0; c < NUMOFENEMIES; c++)
   {
    if(emy[c].life > 0)
    {
     temy=emy[c];
     temy.x+=xd;
     temy.y+=yd;
   executeMe=false;
/*      if(map[temy.mapx-1][temy.mapy] >= DARK)
   {
/*    if(map[temy.mapx-1][temy.mapy+temy.paddy] >= DARK)
    {*/
//     executeMe=true;
/*     for(int f=0; f < NUMOFENEMIES; f++)
     {
      if(f != c)
      {
      if((((temy.x + 16) >= emy[f].x) && (temy.x <= (emy[f].x + 16))))
      {
       executeMe=false;
       goto eol;
      }
      }
     }
     eol:*/
    //}
   //}*/

//   else if(temy.fmapx > floor(temy.fmapx))
 //  executeMe=true;
//    if(executeMe)
 //   {
//     temy.xpp-=2;
 //    temy.fmapx=temy.xpp/16.0;
 temy.zom_move_timer++;
 if(temy.zom_move_timer >= 4)
 {
  temy.zom_move_timer=0;
  if(Random(2) == 0)
  temy.zom_move=1;
  else
  temy.zom_move=0;
 }
 if(temy.zom_move)
 {
 if(temy.x > x+16)
 {
      temy.x-=zomspeed;
                   if(temy.var2 == 48 || temy.var2 == 72)
      temy.var2=0;
      }
      else if(temy.x < x)
      {
       temy.x+=zomspeed;
            if(temy.var2 == 0 || temy.var2 == 24)
      temy.var2=48;
      }
      }
   // }
   // temy.mapx=floor(temy.fmapx);
    //temy.paddx=temy.fmapx == floor(temy.fmapx)?0:1;
    if(attack)
    {
     if(plyr.Variables[1] == RIGHT || plyr.Variables[1] == WALKRIGHT)
     {
      endhitcheck=wpn_width[weapon_in_use]-1;
      starthitcheck=0;
     }
          if(plyr.Variables[1] == LEFT || plyr.Variables[1] == WALKLEFT)
     {
      endhitcheck=0;
      starthitcheck=(wpn_width[weapon_in_use]-1)*-1;
     }
     }
     else
     {
      endhitcheck=0;
      starthitcheck=0;
     }
     for(int b=0; b < 6; b++)
     {
      if(active_bullets[b])
      {
      if(bulletspeed > 0)
      {
     if((bulletx[b]+10 >= temy.x) && (bulletx[b]-(bulletx[b]-befbulletx[b]) <= (temy.x + 16)))
     {
      active_bullets[b]=0;
      goto hurtzom;
     }
     }
     else
     {
           if(((bulletx[b] - (bulletx[b]-befbulletx[b])) >= temy.x) && (bulletx[b] <= (temy.x + 16)))
     {
            active_bullets[b]=0;
      goto hurtzom;
     }
     }
     befbulletx[b]=bulletx[b];
      }
     }
     if(((x + 16 + endhitcheck) >= temy.x) && (x + starthitcheck <= (temy.x + 16)))
     {
         if(attack)
    {
     hurtzom:
      particle_timer=0;
      PlayFile("hit_blood_spat.rso");
      temy.life--;
      particle_count=6;
      particlepower=10;
       for(int e=0; e < Random(particle_count-2)+2; e++)
 {
  particleangle=Random(40)-10;
  particleax[e]=cosd(particleangle)*6;
  particleay[e]=sind(particleangle)*6;
  particlex[e]=temy.x+8;
  particley[e]=temy.y+8;
 }
       DrawParticles=1;
 }
 else
 {
  life--;
  //PlayFile("zattack.rso");
//  bDisplayWhiteOut=true;
  if(life <= 0)
  {
   StopTask(tiles);
   Wait(500);
   byte vartt[1];
   until(ButtonPressed(BTNCENTER,0))
   {
         vartt[0]=0;
    SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"death.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
  vartt[0]=100;
    SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"death.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
  vartt[0]=200;
      SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"death.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
   }
   Wait(100);
   StopAllTasks();
  }
 }
     }
    if(temy.life <= 0)
    {
           deademy=1;
           money+=5;
      particle_timer=0;
      particlepower=40;
      particle_count=10;
      temy.life=zomlife;
       for(int e=0; e < 15; e++)
 {
  particleangle=Random(220)-20;
  particleax[e]=cosd(particleangle)*7;
  particleay[e]=sind(particleangle)*7;
  particlex[e]=temy.x+8;
  particley[e]=temy.y+8;
  if(e == 13)
  {
  particleangle=88+Random(6);
  particleax[e]=cosd(particleangle)*8;
  particleay[e]=sind(particleangle)*8;
  particlex[e]=temy.x+8;
  particley[e]=temy.y+8;
  }
 }     if(xadd <= -20)
       {
        switch(Random(2))
        {
         case 0:
         temy.x=xadd+1*16;
         break;
         case 1:
         temy.x=xadd+17*16;
         break;
        }
       }
       else
       {
       temy.x=xadd+17*16;
       }
      temy.y=yadd+16;
            DrawParticles=1;
    }
    emy[c]=temy;
    }
   }
         xd=0;
   yd=0;
   Wait(120-(CurrentTick()-t0z));
 }
}


task main()
{
 SetSensorTouch(S1);
 gib_var[1]=DRAW_OPT_LOGICAL_XOR;
 for(int c=0; c < width; c++)
 {
  for(int d=0; d < height; d++)
  {
   map[c][d]=DARK;
  }
 }
 for(int c=0; c < width; c++)
 {
  map[c][0]=GRASS;
 }
  for(int c=0; c < width; c++)
 {
  map[c][height-1]=GRASS;
 }
  for(int c=0; c < height; c++)
 {
  map[0][c]=GRASS;
 }
   for(int c=0; c < height; c++)
 {
  map[width-1][c]=GRASS;
 }
// PlaceSkeletonStatue(11,1);
 EnemyInit(0,ZOMBIE,12,1,zomlife);
 EnemyInit(1,ZOMBIE,15,1,zomlife);
 EnemyInit(2,ZOMBIE,18,1,zomlife);
 EnemyInit(3,ZOMBIE,20,1,zomlife);
 EnemyInit(4,ZOMBIE,22,1,zomlife);
 EnemyInit(5,ZOMBIE,16,1,zomlife);
/* EnemyInit(6,ZOMBIE,17,1,6);
 EnemyInit(7,ZOMBIE,18,1,6);
 EnemyInit(8,ZOMBIE,19,1,6);
 EnemyInit(9,ZOMBIE,20,1,6);
 EnemyInit(10,ZOMBIE,18,1,6);
 EnemyInit(11,ZOMBIE,19,1,6);
 EnemyInit(12,ZOMBIE,20,1,6);
 EnemyInit(13,ZOMBIE,21,1,6);
 EnemyInit(14,ZOMBIE,22,1,6);*/

 map[13][1]=GRAVESTONE;
 map[16][1]=GRAVESTONE;
 map[18][1]=GRAVESTONE;
 mapx=2;
 mapy=1;
 fmapx=2;
 fmapy=1;
 x=32;
 y=16;
 xpp=mapx*16;
 ypp=mapx*16;
 byte vartt[1];
 life=40;
 wpn_width[0]=8;
 wpn_width[1]=13;
 wpn_width[2]=20;
 wpn_width[3]=8;
 wpn_width[4]=8;
 wpn_cost[1]=30;
 wpn_cost[2]=50;
 wpn_cost[3]=70;
  wpn_cost[4]=120;
 weapon_in_use=SWORD;
      switch(weapon_in_use)
  {
   case SWORD:
   weapon_filename="wpn_sword.ric";
   break;
   case LONGSWORD:
   weapon_filename="wpn_lngsword.ric";
   break;
   case STAFF:
   weapon_filename="wpn_staff.ric";
   break;
   case PISTOL:
   weapon_filename="wpn_pistol.ric";
   break;
      case MACHINEGUN:
   weapon_filename="wpn_mgun.ric";
   break;
  }
 SetDisplayContrast(83);
 until(ButtonPressed(BTNCENTER,0))
 {
    vartt[0]=0;
    SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"title.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
  vartt[0]=100;
    SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"title.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
  vartt[0]=200;
      SetDisplayFlags( DISPLAY_REFRESH_DISABLED );
  GraphicOutEx(0,0,"title.ric",vartt);
  SetDisplayFlags( DISPLAY_ON | DISPLAY_REFRESH );
  Wait(17);
 }
 Precedes(tiles,engine);
}
Thanks, and have a nice day,
nxtboy III

programnxt.com
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: My new NXT game- After Dark, in grayscale

Post by nxtboyiii »

Doc- did you see the code? Do you need help with something?

Does anybody have any comments about this project? It seems as if hardly anybody is commenting.

EDIT: I posted the program (.rxe and .rics) to the game in the main post.
Thanks, and have a nice day,
nxtboy III

programnxt.com
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests