Advertisement
ZoriaRPG

Atari Game (Alpha 0.3.2)

Aug 26th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.00 KB | None | 0 0
  1. // Atari Game Script
  2. // v0.3
  3. // 24th August, 2018
  4. // By: ZoriaRPG
  5.  
  6. import "std.zh"
  7.  
  8. const float MOVE_RATE = 1;
  9.  
  10. const int PLAYER_WIDTH = 5;
  11. const int PLAYER_HEIGHT = 8;
  12.  
  13. const int MIN_ZC_ALPHA_BUILD = 35; //Alphas are negatives, so we neex to check maximum, not minimum.
  14.  
  15. typedef const int DEFINE;
  16.  
  17. //PALETTE INDEX COLUMN FOR EACH GAME OBJECT
  18.  
  19.  
  20.  
  21. DEFINE COL_BACKGROUND       = 0x00;
  22. DEFINE COL_DOOR         = 0x01;
  23. DEFINE COL_PLAYER       = 0x02;
  24. DEFINE COL_WALL         = 0x04;
  25.  
  26. DEFINE COL_ENEMY_WEAPON     = 0x08;
  27. DEFINE COL_PLAYER_WEAPON    = 0x09;
  28. DEFINE COL_ENEMY        = 0x0A;
  29.  
  30. DEFINE COL_ITEM         = 0x0F;
  31.  
  32. ffc player;
  33.  
  34.  
  35. global script Atari
  36. {
  37.     void run()
  38.     {
  39.  
  40.         player = Screen->LoadFFC(1);
  41.         player->Data = 188;
  42.         bitmap playfield = Game->LoadBitmapID(RT_SCREEN);
  43.         Link->Invisible = true; Link->DrawYOffset = -32768;
  44.        
  45.         check_min_zc_build();
  46.        
  47.         while(1)
  48.         {
  49.             Link->X = 60;
  50.             Link->Y = 60;
  51.             if ( Input->Press[CB_LEFT] )
  52.             {
  53.                 if ( canmove(DIR_LEFT, player, playfield) )
  54.                 {
  55.                     --player->X;
  56.                 }
  57.             }
  58.             if ( Input->Hold[CB_LEFT] )
  59.             {
  60.                 if ( canmove(DIR_LEFT, player, playfield) )
  61.                 {
  62.                     --player->X;
  63.                 }
  64.             }
  65.             if ( Input->Press[CB_DOWN] )
  66.             {
  67.                 if ( canmove(DIR_DOWN, player, playfield) )
  68.                 {
  69.                     ++player->Y;
  70.                 }
  71.             }
  72.             if ( Input->Hold[CB_DOWN] )
  73.             {
  74.                 if ( canmove(DIR_DOWN, player, playfield) )
  75.                 {
  76.                     ++player->Y;
  77.                 }
  78.             }
  79.             if ( Input->Press[CB_UP] )
  80.             {
  81.                 if ( canmove(DIR_UP, player, playfield) )
  82.                 {
  83.                     --player->Y;
  84.                 }
  85.             }
  86.             if ( Input->Hold[CB_UP] )
  87.             {
  88.                 if ( canmove(DIR_UP, player, playfield) )
  89.                 {
  90.                     --player->Y;
  91.                 }
  92.             }
  93.             if ( Input->Press[CB_RIGHT] )
  94.             {
  95.                 if ( canmove(DIR_RIGHT, player, playfield) )
  96.                 {
  97.                     ++player->X;
  98.                 }
  99.             }
  100.             if ( Input->Hold[CB_RIGHT] )
  101.             {
  102.                 if ( canmove(DIR_RIGHT, player, playfield) )
  103.                 {
  104.                     ++player->X;
  105.                 }
  106.             }
  107.             Waitdraw();
  108.             Waitframe();
  109.         }
  110.     }
  111.     bool canmove(int dir, ffc p, bitmap bmp)
  112.     {
  113.         int col[8]; bool coll = true;
  114.         switch(dir)
  115.         {
  116.            
  117.             case DIR_RIGHT:
  118.             {
  119.                 TraceS("Right");
  120.                 for ( int q = 0; q < PLAYER_HEIGHT; ++q )
  121.                 {
  122.                     col[q] = bmp->GetPixel(p->X+PLAYER_WIDTH, p->Y+q) * 10000;
  123.                     Trace(bmp->GetPixel(p->X-1, p->Y+q));
  124.                 }
  125.                 for ( int q = 0; q < PLAYER_HEIGHT; ++ q )
  126.                 {
  127.                     if ( ( col[q] % 16 ) != 0 )
  128.                     {
  129.                         TraceNL(); TraceS("Pixel Colour Was: "); Trace(col);
  130.                         return false;
  131.                     }
  132.                 }
  133.                 return true;
  134.             }
  135.             case DIR_LEFT:
  136.             {
  137.                 TraceS("Left");
  138.                 for ( int q = 0; q < PLAYER_HEIGHT; ++q )
  139.                 {
  140.                     col[q] = bmp->GetPixel(p->X-1, p->Y+q) * 10000;
  141.                     Trace(bmp->GetPixel(p->X-1, p->Y+q));
  142.                 }
  143.                
  144.                 for ( int q = 0; q < PLAYER_HEIGHT; ++q )
  145.                 {
  146.                     if ( ( col[q] % 16 ) != 0 )
  147.                     {
  148.                         return false;
  149.                     }
  150.                 }
  151.                 return true;
  152.             }
  153.             case DIR_UP:
  154.             {
  155.                 TraceS("Up");
  156.                 for ( int q = 0; q < PLAYER_WIDTH; ++q )
  157.                 {
  158.                     col[q] = bmp->GetPixel(p->X+q, p->Y-1) * 10000;
  159.                     Trace(bmp->GetPixel(p->X-1, p->Y+q));
  160.                 }
  161.                 for ( int q = 0; q < PLAYER_WIDTH; ++ q )
  162.                 {
  163.                     if ( ( col[q] % 16 ) != 0 )
  164.                     {
  165.                         return false;
  166.                     }
  167.                 }
  168.                 return true;
  169.             }
  170.             case DIR_DOWN:
  171.             {
  172.                 TraceS("Down");
  173.                 for ( int q = 0; q < PLAYER_WIDTH; ++q )
  174.                 {
  175.                     col[q] = bmp->GetPixel(p->X+q, p->Y+PLAYER_HEIGHT) * 10000;
  176.                     Trace(bmp->GetPixel(p->X-1, p->Y+q));
  177.                 }
  178.                 for ( int q = 0; q < PLAYER_WIDTH; ++q )
  179.                 {
  180.                     if ( ( col[q] % 16 ) != 0 )
  181.                     {
  182.                         return false;
  183.                     }
  184.                 }
  185.                 return true;
  186.             }
  187.             //default: return false;
  188.         }
  189.         return true;
  190.     }
  191.     void check_min_zc_build()
  192.     {
  193.         if ( Game->Beta < MIN_ZC_ALPHA_BUILD )
  194.         {
  195.             //Game->PlayMIDI(9);
  196.             int v_too_early = 600; int req_vers[3]; itoa(req_vers, MIN_ZC_ALPHA_BUILD);
  197.             TraceNL(); int vers[3]; itoa(vers,Game->Beta);
  198.             TraceS("This version of Atari.qst requires Zelda Classic v2.54, Alpha (");
  199.             TraceS(req_vers);
  200.             TraceS("), or later.");
  201.             TraceNL();
  202.             TraceS("I'm detecting Zelda Classic v2.54, Alpha (");
  203.             TraceS(vers);
  204.             TraceS(") and therefore, I must refuse to run. :) ");
  205.             TraceNL();
  206.            
  207.             while(v_too_early--)
  208.             {
  209.                 //Screen->DrawString(7, 4, 40, 1, 0x04, 0x5F, 0,
  210.                 //"This version of Arkanoid.qst requires Zelda Classic 2.54, Alpha 32",
  211.                 //128);
  212.                 Screen->DrawString(7, 15, 40, 1, 0x04, 0x5F, 0,
  213.                 "You are not using a version of ZC adequate to run         ",
  214.                 128);
  215.                
  216.                 Screen->DrawString(7, 15, 55, 1, 0x04, 0x5F, 0,
  217.                 "this quest. Please see allegro.log for details.                   ",
  218.                 128);
  219.            
  220.                 Waitdraw();
  221.                 WaitNoAction();
  222.             }
  223.             Game->End();
  224.            
  225.         }
  226.     }
  227. }
  228.  
  229. global script Init
  230. {
  231.     void run()
  232.     {
  233.         Link->Invisible = true; Link->DrawYOffset = -32768;
  234.     }
  235. }
  236.  
  237. global script init
  238. {
  239.     void run()
  240.     {
  241.         Link->Invisible = true; Link->DrawYOffset = -32768;
  242.     }
  243. }
  244.  
  245. global script onContinue
  246. {
  247.     void run()
  248.     {
  249.         Link->Invisible = true; Link->DrawYOffset = -32768;
  250.     }
  251. }
  252.  
  253. ffc script Atari_version_0_3_2
  254. {
  255.     void run(){}
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement