コード例 #1
0
ファイル: screens.c プロジェクト: CalivmaInnovation/FlyBoard
void credits() {
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("CREDITS", getScreenPosition(6, 0), 15, 0);

	cpct_drawStringM0 ("DEVELOPERS", getScreenPosition(5, 3), 15, 0);
	cpct_drawStringM0 ("Cesar Ivorra Oliver", getScreenPosition(1, 5), 15, 0);
	cpct_drawStringM0 ("Alex Almira Molla", getScreenPosition(1, 7), 15, 0);

	cpct_drawStringM0 ("GAME POWERED BY", getScreenPosition(2, 11), 15, 0);
	cpct_drawStringM0 ("CPCtelera", getScreenPosition(5, 13), 15, 0);

	cpct_drawStringM0 ("SPECIAL THANKS", getScreenPosition(3, 18), 15, 0);
	cpct_drawStringM0 ("Francisco Gallego", getScreenPosition(1, 20), 15, 0);

	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go main menu", getScreenPosition(2, 24), 15, 0);
	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_waitVSYNC();
		cpct_akp_musicPlay();

		cpct_scanKeyboard_f ();
	}
	gameScene=MENUSCREEN;
}
コード例 #2
0
ファイル: game.c プロジェクト: AugustoRuiz/cpctelera
////////////////////////////////////////////////////////////////////////////////
// Waits for a key to be pressed, but from a previous state of not being pressed
//
void wait4Key(cpct_keyID key) {
   do
      cpct_scanKeyboard_f();
   while( ! cpct_isKeyPressed(key) );
   do
      cpct_scanKeyboard_f();
   while( cpct_isKeyPressed(key) );
}
コード例 #3
0
ファイル: screens.c プロジェクト: CalivmaInnovation/FlyBoard
void mainMenu() {
		u8 option=0;
		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("CONTROLS", getScreenPosition(5, 7), 15, 7);
		cpct_drawStringM0 ("CREDITS", getScreenPosition(5, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
		    waitNVSYNCs(3);
			cpct_akp_musicPlay();

			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 2) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 5), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 5), 4, 8);
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 7), 4, 8);
					break;
				case 2:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
    		case 0:	playMenu();
				break;
    		case 1: 
				gameScene=CONTROLSSCREEN;
				break;
		    case 2: 
				gameScene=CREDITSSCEENE;
				break;
		}
}
コード例 #4
0
ファイル: screens.c プロジェクト: CalivmaInnovation/FlyBoard
void playMenu() {
		u8 option=0;

		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("INFINITY MODE", getScreenPosition(6, 7), 15, 7);
		cpct_drawStringM0 ("LEVELS MODE", getScreenPosition(6, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
			waitNVSYNCs(3);
			cpct_akp_musicPlay();
			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_Esc)) {
				gameScene=MENUSCREEN;
				return;
			}
			else if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 1) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 7), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
			case 0:
				cpct_akp_stop();
				gameScene=PLAYGAMESCREEN;
				break;
			case 1:
				cpct_akp_stop();
				gameScene=NEXTLEVELSCREEN;
				break;
		}
}
コード例 #5
0
ファイル: main.c プロジェクト: AugustoRuiz/cpctelera
/////////////////////////////////////////////////////////////////////////////////
// Wait for a given key to be pressed
//
void wait4Key(cpct_keyID key) {
   // First, if the key is already pressed, wait for 
   // it being released
   do
      cpct_scanKeyboard_f();
   while(cpct_isKeyPressed(key));

   // And now, wait for the key being pressed again
   do
      cpct_scanKeyboard_f();
   while(!cpct_isKeyPressed(key));
}
コード例 #6
0
ファイル: screens.c プロジェクト: CalivmaInnovation/FlyBoard
void newLevel() {
	u8 str[6];
	initLevel();
	sprintf(str, "%2u", level);
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("LEVEL", getScreenPosition(7, 11), 15, 0);
	cpct_drawStringM0 (str, getScreenPosition(13, 11), 15, 0);
	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go next level", getScreenPosition(2, 24), 15, 0);
	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_scanKeyboard_f ();
	}
	levelMode();
}
コード例 #7
0
ファイル: game.c プロジェクト: johnlobo/Amsthrees
void drawScoreBoard() {
    u8 i;
    u32 c = 0;

    cpct_waitVSYNC();

    cpct_memset(CPCT_VMEM_START, cpct_px2byteM0(0, 0), 0x4000);

    drawText("AMSTHREES SCOREBOARD", 13, 2, 1);

    for (i = 0; i < 8; i++) {
        drawNumber(i + 1, 2, 5, 30 + (i * 15));
        drawText(nameHallOfFame[i], 14, 30 + (i * 15), 0);
        drawNumber(scoreHallOfFame[i], 1, 69, 30 + (i * 15));
    }

    drawText("JOHN LOBO", 25, 170, 1);
    drawText("@ GLASNOST CORP 2016", 11, 185, 1);

    c = 40000;     // Number of loops passed if not keypressed
    // Wait 'till the user presses a key, counting loop iterations
    do {
        c--;                       // One more cycle
        cpct_scanKeyboard_f();     // Scan the keyboard
    } while (( ! cpct_isAnyKeyPressed_f() ) && c > 0);
    //delay(2000);
}
コード例 #8
0
ファイル: main.c プロジェクト: amm297/amstrad
/* Controles */
void controles(){
  u8* memptr;
  cpct_clearScreen(0);

  memptr = cpct_getScreenPtr(VMEM, 23, 60); 
  cpct_drawStringM0("Controles:", memptr, 1, 0); 
  
  memptr = cpct_getScreenPtr(VMEM, 11, 80); 
  cpct_drawStringM0("Movimiento: ", memptr, 2, 0); 
  memptr = cpct_getScreenPtr(VMEM, 27, 95); 
  cpct_drawStringM0("Flechas", memptr, 2, 0); 
  
  memptr = cpct_getScreenPtr(VMEM, 13, 115); 
  cpct_drawStringM0("Esc: Menu", memptr, 2, 0); 
  memptr = cpct_getScreenPtr(VMEM, 13, 130); 
  cpct_drawStringM0("Disparar: X", memptr, 2, 0); 

  memptr = cpct_getScreenPtr(VMEM, 12, 175); 
  cpct_drawStringM0("Pulsa espacio", memptr, 1, 0); 

   while (1){
    cpct_scanKeyboard_f();
     if(cpct_isKeyPressed(Key_Space)) {

        return;
      }

   }
}
コード例 #9
0
ファイル: game.c プロジェクト: AugustoRuiz/cpctelera
////////////////////////////////////////////////////////////////////////////////
// Scan Keyboard and update user actions as requested by the user
//
void updateUser(TCharacter* user) {
   // Scan Keyboard
   cpct_scanKeyboard_f();

   //
   // Check possible keys to press, and do actions
   //

   // KEY = Cursor Up, ACTION = Jump (only when not already jumping)
   if ( cpct_isKeyPressed(Key_CursorUp) && user->status != es_jump ) {
      performAction(user, es_jump, user->side);    // Perform the action of jumping
      getRandomUniform(user->entity.nx);           // Use X coordinate of the user when jumping to forward update the random seed
   
   // KEY = Cursor Right, ACTION = Walk Right
   } else if ( cpct_isKeyPressed(Key_CursorRight) )
      performAction(user, es_walk, s_right);       // Move player to the right

   // KEY = Cursor Left, ACTION = Walk Left
   else if ( cpct_isKeyPressed(Key_CursorLeft) ) 
      performAction(user, es_walk, s_left);        // Move player to the left

   // KEY = Cursor Down, ACTION = Move Floor
   else if ( cpct_isKeyPressed(Key_CursorDown) ) 
      performAction(user, es_moveFloor, user->side); // Enable moving floor

   // KEY = None pressed, ACTION = Change user to static
   else 
      performAction(user, es_static, user->side);
}
コード例 #10
0
ファイル: main.c プロジェクト: amm297/amstrad
/* CREDITOS */
void credits(){
u8* memptr;
  cpct_clearScreen(0);

  memptr = cpct_getScreenPtr(VMEM, 18, 30); 
  cpct_drawStringM0("Grupo Pyxis", memptr, 1, 0); 

  memptr = cpct_getScreenPtr(VMEM, 23, 60); 
  cpct_drawStringM0("Miembros:", memptr, 1, 0); 
  
  memptr = cpct_getScreenPtr(VMEM, 10, 80); 
  cpct_drawStringM0("Alberto Martinez", memptr,2, 0); 
  memptr = cpct_getScreenPtr(VMEM, 27, 95); 
  cpct_drawStringM0("Martinez", memptr,2, 0); 
  
  memptr = cpct_getScreenPtr(VMEM, 13, 115); 
  cpct_drawStringM0("Josep Domenech", memptr,2, 0);
  memptr = cpct_getScreenPtr(VMEM, 27, 125); 
  cpct_drawStringM0("Mingot", memptr, 2, 0);  

  memptr = cpct_getScreenPtr(VMEM, 12, 175); 
  cpct_drawStringM0("Pulsa espacio", memptr, 1, 0); 



  while (1){
    cpct_scanKeyboard_f();
     if(cpct_isKeyPressed(Key_Space)) {

        return;
      }

   }
}
コード例 #11
0
ファイル: main.c プロジェクト: Trewdbal/cpctelera
/////////////////////////////////////////////////////////////////////////////////
// Read User Keyboard Input and do associated actions
//
i16 wait4KeyboardInput(){
   // Read keyboard continuously until the user perfoms an action
   while(1) {
      // Scan Keyboard
      cpct_scanKeyboard_f(); 

      // Check user keys for controlling scroll. If one of them is pressed
      // return the associated scroll offset.
      if      (cpct_isKeyPressed(Key_CursorRight)) return  1;
      else if (cpct_isKeyPressed(Key_CursorLeft))  return -1;
   }
}
コード例 #12
0
ファイル: screens.c プロジェクト: CalivmaInnovation/FlyBoard
void controls() {
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("CONTROLS", getScreenPosition(5, 3), 15, 0);

	cpct_drawStringM0 ("W: Move Up", getScreenPosition(4, 7), 15, 0);
	cpct_drawStringM0 ("S: Move Down", getScreenPosition(4, 9), 15, 0);
	cpct_drawStringM0 ("A: Move Left", getScreenPosition(4, 11), 15, 0);
	cpct_drawStringM0 ("D: Move Right", getScreenPosition(4, 13), 15, 0);

	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go main menu", getScreenPosition(2, 24), 15, 0);

	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_waitVSYNC();
		cpct_akp_musicPlay();
		cpct_scanKeyboard_f ();
	}
	// gameScene=MENUSCREEN;
	gameScene=MENUSCREEN;
}
コード例 #13
0
ファイル: main.c プロジェクト: AugustoRuiz/cpctelera
/////////////////////////////////////////////////////////////////////////////////
// Read User Keyboard Input and do associated actions
//
void readKeyboardInput(TScreenTilemap *scr){
   
   // Read keyboard continuously until the user perfoms an action
   while(1) {
      // Scan Keyboard
      cpct_scanKeyboard_f(); 

      // Check all the user keys one by one and, if one of them is pressed
      // perform the action and return to the application
      //
      if (cpct_isKeyPressed(Key_CursorUp) && scr->y) {
         scr->y -= 4;   // Move Tilemap Up (4 by 4 pixels, as it can only be placed
         return;        // ... on pixel lines 0 and 4
      } else if (cpct_isKeyPressed(Key_CursorDown) && scr->y < (SCR_HEIGHT - 4*MAP_HEIGHT)) {
         scr->y += 4;   // Move Tilemap Down (same as moving Up, 4 by 4 pixels)
         return;
      } else if (cpct_isKeyPressed(Key_CursorLeft) && scr->x) {
         --scr->x;      // Move Tilemap Left 2 pixels (1 byte)
         return;
      } else if (cpct_isKeyPressed(Key_CursorRight) && scr->x < (SCR_WIDTH - 2*MAP_WIDTH)) {
         ++scr->x;      // Move Tilemap Right 2 pixels (1 byte)
         return;
      } else if (cpct_isKeyPressed(Key_2) && scr->viewport.x + scr->viewport.w < MAP_WIDTH) {
         ++scr->viewport.w;   // Enlarge viewport Horizontally
         return;
      } else if (cpct_isKeyPressed(Key_1) && scr->viewport.w > 1) {
         --scr->viewport.w;   // Reduce viewport Horizontally
         return;
      } else if (cpct_isKeyPressed(Key_4) && scr->viewport.y + scr->viewport.h < MAP_HEIGHT) {
         ++scr->viewport.h;   // Enlarge viewport Vertically
         return;
      } else if (cpct_isKeyPressed(Key_3) && scr->viewport.h > 1) {
         --scr->viewport.h;   // Reduce viewport Vertically
         return;
      } else if (cpct_isKeyPressed(Key_W) && scr->viewport.y) {
         --scr->viewport.y;   // Move viewport Up
         return;
      } else if (cpct_isKeyPressed(Key_S) && scr->viewport.y + scr->viewport.h < MAP_HEIGHT) {
         ++scr->viewport.y;   // Move viewport Down
         return;
      } else if (cpct_isKeyPressed(Key_A) && scr->viewport.x) {
         --scr->viewport.x;   // Move viewport Left
         return;
      } else if (cpct_isKeyPressed(Key_D) && scr->viewport.x + scr->viewport.w < MAP_WIDTH) {
         ++scr->viewport.x;   // Move viewport Right
         return;
      }
   }
}
コード例 #14
0
ファイル: main.c プロジェクト: mattl/cpctelera
//
// EXAMPLE: Measuring free cycles after moving an sprite
//
void main(void) {
   u8  i;                        // Loop index
   u8  x=0, y=0;                 // Sprite coordinates (in bytes)
   u8* pvideomem = (u8*)0xC000;  // Sprite initial video memory byte location (where it will be drawn)
   u16 avc = 0;                  // Available cycles until next VSYNC, after all main loop calculations

   // First, disable firmware to prevent it from intercepting our palette and video mode settings (and,
   // at the same time, winning some speed not having to process firmware code at every interrupt)
   cpct_disableFirmware();
   // Set palette and Screen Border (transform firmware to hardware colours and then set them)
   cpct_fw2hw     (G_palette, 4);
   cpct_setPalette(G_palette, 4);
   cpct_setBorder (G_palette[1]);
   // Ensure MODE 1 is set
   cpct_setVideoMode(1);

   // Main Loop
   while(1) {
      // First, wait VSYNC monitor signal to synchronize the loop with it. We'll start doing
      // calculations always at the same time (when VSYNC is first detected)
      cpct_waitVSYNC();

      // Scan Keyboard and change sprite location if cursor keys are pressed
      cpct_scanKeyboard_f();
      if      (cpct_isKeyPressed(Key_CursorRight) && x <  80 - SPR_W) { x++; pvideomem++; }
      else if (cpct_isKeyPressed(Key_CursorLeft)  && x >   0        ) { x--; pvideomem--; }
      if      (cpct_isKeyPressed(Key_CursorUp)    && y >   0        ) { pvideomem -= (y-- & 7) ? 0x0800 : 0xC850; }
      else if (cpct_isKeyPressed(Key_CursorDown)  && y < 200 - SPR_H) { pvideomem += (++y & 7) ? 0x0800 : 0xC850; }

      // Draw the sprite at its new location on screen. 
      // Sprite automatically erases previous copy of itself on the screen because it moves 
      // 1 byte at a time and has a 0x00 border that overwrites previous colours on that place
      cpct_drawSprite(G_death, pvideomem, SPR_W, SPR_H);
      
      // Wait to next VSYNC signal, calculating the amount of free cycles (time we wait for VSYNC)
      // As documented on <cpct_count2VSYNC>, function returns number of loop iterations (L), and 
      // cycles shall be calculated doing 22 + 34*L
      avc = 22 + 34 * cpct_count2VSYNC();

      // Print 5 digits on the upper right corner of the screen, 
      // with the amount of free cycles calculated in previous step. 
      // Digits will be printed at screen locations (0xC046, 0xC048, 0xC04A, 0xC04C, 0xC04E)
      for(i=0; i<5; i++) {
         u8 digit = '0' + (avc % 10);
         cpct_drawCharM1_f((void*)(0xC04E - 2*i), 3, 0, digit);
         avc /= 10;
      }
   }
}
コード例 #15
0
ファイル: main.c プロジェクト: AugustoRuiz/cpctelera
//
// MAIN: Using keyboard to move a sprite example
//
void main(void) {
   u8 x=20;                     // Sprite horizontal coordinate
   u8 lookingAt = LOOK_RIGHT;   // Know where the sprite is looking at 
   u8 nowLookingAt = lookingAt; // New looking direction after keypress

   // Initialize the Amstrad CPC
   initialize();

   // 
   // Infinite moving loop
   //
   while(1) {
      u8* pvideomem; // Pointer to video memory

      // Scan Keyboard (fastest routine)
      // The Keyboard has to be scanned to obtain pressed / not pressed status of
      // every key before checking each individual key's status.
      cpct_scanKeyboard_f();

      // Check if user has pressed a Cursor Key and, if so, move the sprite if
      // it will still be inside screen boundaries
      if (cpct_isKeyPressed(Key_CursorRight) && x < (SCR_W - SP_W) ) {
         ++x;
         nowLookingAt = LOOK_RIGHT;
      } else if (cpct_isKeyPressed(Key_CursorLeft)  && x > 0) {
         --x; 
         nowLookingAt = LOOK_LEFT;
      }

      // Check if we have changed looking direction      
      if (lookingAt != nowLookingAt) {
         lookingAt = nowLookingAt;
         cpct_hflipSpriteM0(SP_W, SP_H, g_spirit);
      }

      // Get video memory byte for coordinates x, y of the sprite (in bytes)
      pvideomem = cpct_getScreenPtr(CPCT_VMEM_START, x, FLOOR_Y - SP_H);

      // Draw the sprite in the video memory location got from coordinates x, y
      cpct_drawSprite(g_spirit, pvideomem, SP_W, SP_H);
   }
}
コード例 #16
0
ファイル: main.c プロジェクト: AugustoRuiz/cpctelera
//
// MAIN: Using keyboard to move a sprite example
//
void main(void) {
   u8  x=10, y=10;   // Sprite coordinates
   u8* pvideomem;    // Pointer to video memory

   //
   // Set up the screen
   //
   // Disable firmware to prevent it from interfering with setPalette and setVideoMode
   cpct_disableFirmware();

   // Set the colour palette
   cpct_fw2hw     (G_palette, 4); // Convert our palette from firmware to hardware colours 
   cpct_setPalette(G_palette, 4); // Set up the hardware palette using hardware colours
   
   // Set video mode 1 (320x200, 4 colours)
   cpct_setVideoMode(1);

   // 
   // Infinite moving loop
   //
   while(1) {
      // Scan Keyboard (fastest routine)
      // The Keyboard has to be scanned to obtain pressed / not pressed status of
      // every key before checking each individual key's status.
      cpct_scanKeyboard_f();

      // Check if user has pressed a Cursor Key and, if so, move the sprite if
      // it will still be inside screen boundaries
      if      (cpct_isKeyPressed(Key_CursorRight) && x < (SCR_W - SP_W) ) ++x; 
      else if (cpct_isKeyPressed(Key_CursorLeft)  && x > 0              ) --x; 
      if      (cpct_isKeyPressed(Key_CursorUp)    && y > 0              ) --y;
      else if (cpct_isKeyPressed(Key_CursorDown)  && y < (SCR_H - SP_H) ) ++y;
      
      // Get video memory byte for coordinates x, y of the sprite (in bytes)
      pvideomem = cpct_getScreenPtr(CPCT_VMEM_START, x, y);

      // Draw the sprite in the video memory location got from coordinates x, y
      cpct_drawSprite(G_spriteLogoCT, pvideomem, SP_W, SP_H);
   }
}
コード例 #17
0
ファイル: main.c プロジェクト: amm297/amstrad
/*GAME OVER*/
void gameOver(){
    u8* memptr;
  cpct_clearScreen(0);
  memptr = cpct_getScreenPtr(VMEM,10,10);
  cpct_drawStringM0("Lounge Gladiator",memptr,1,0);

    memptr = cpct_getScreenPtr(VMEM,10,50);
   cpct_drawSprite(gameover,memptr,60,28);


  memptr = cpct_getScreenPtr(VMEM, 12, 175); 
  cpct_drawStringM0("Pulsa espacio", memptr, 1, 0); 



  while (1){
    cpct_scanKeyboard_f();
     if(cpct_isKeyPressed(Key_Space)) {

        return;
      }

   }
}
コード例 #18
0
ファイル: main.c プロジェクト: amm297/amstrad
/*JUEGO*/
void game(){
  u8 atkObj = 0;

  initVariables(1);
  initPlayer(map);
  initNivel();
  initEnemies(map);

   cpct_clearScreen(0);
   drawMap(map);
   while (1){
    if(finish == 1) return;
    //Esperar el retrazado
    cpct_waitVSYNC();

    //Desdibujar personajes
    erases();

    //Dibujar pickups
    if(temp == 10)
        drawPickUps(n.corazon,n.bullet);

    //Dibujar personajes
    draws();

    //Dibujar fatiga
    if(temp == 10){
        if(player.atk < 20) drawFatiga(player.atk,2);
        else if(player.atk > 20) drawFatiga(player.atk,1);
        else drawFatiga(player.atk,0);
    }
    //guardar datos anteriores
    if(temp%2 == 0){
        player.lx = player.x;
        player.ly = player.y;
    }

    if(enemy.life > 0){
        if(temp%2 == 1){
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
        }

       move();
        switch(checkCollisions(player.x, player.y, enemy.x, enemy.y, player.atk)){
          case 1:
            erase(enemy.lx,enemy.ly,0);
            enemy.x = enemy.ox;
            enemy.y = enemy.oy;
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
            enemy.ox = originse[map-1][4];
            enemy.oy = originse[map-1][5];
            enemy.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
          case 2:
            erase(player.lx,player.ly,0);
            player.x =originsp[map-1][0];
            player.y = originsp[map-1][1];
            player.lx =originsp[map-1][0];
            player.ly = originsp[map-1][1];
            player.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
        }
    }
    if(temp > 10)
        temp = 0;
    temp += 1;
    player.latk = player.atk;
      //Comprobar teclado
      cpct_scanKeyboard_f();
      player.sprite = checkKeyboard();
      checkBoundsCollisions(&n.corazon,&n.bullet);

      if(arrow == 1){
        moveObject();
        bound = checkArrowCollisions();
        if(object.dir == 2 || object.dir == 8)
            atkObj = 21;
        else
            atkObj = 22;
       if(enemy.life > 0 && checkCollisions(object.x, object.y, enemy.x, enemy.y, atkObj) == 1 && bound == 0){
         enemy.life -= 1;
         erase(enemy.lx,enemy.ly,0);
         enemy.x = enemy.ox;
         enemy.y = enemy.oy;
         enemy.lx = enemy.x;
         enemy.ly = enemy.y;
         enemy.pursue = 0;
         object.vivo = 0;
         bound = 1;
       }
      }
      
      if(player.life == 0){
        gameOver();
        finish = 1;
      } 
      

   }
}
コード例 #19
0
ファイル: main.c プロジェクト: AugustoRuiz/cpctelera
////////////////////////////////////////////////////////////////////////
// MAIN: Arkos Tracker Music Example
//    Keys:
//       * SPACE - Start / Stop Music
//       *   1   - Play a sound effect on Channel A
//       *   2   - Play a sound effect on Channel C
//
void main(void) {
   TKeyStatus k_space, k_0, k_1;    // Status of the 3 Keys for this example (Space, 1, 2)
   u8  playing   = 1;               // Flag to know if music is playing or not
   u8  color     = 1;               // Color to draw charactes (normal / inverse)
   u8* pvideomem = CPCT_VMEM_START; // Pointer to video memory where next character will be drawn

   // All 3 keys are considered to be released at the start of the program
   k_space = k_0 = k_1 = K_RELEASED;

   // Initialize CPC
   cpct_disableFirmware(); // Disable firmware to prevent interaction
   cpct_setVideoMode(2);   // Set Mode 2 (640x200, 2 colours)

   // Initialize the song to be played
   cpct_akp_musicInit(molusk_song);    // Initialize the music
   cpct_akp_SFXInit(molusk_song);      // Initialize instruments to be used for SFX (Same as music song)

   while (1) {
      // We have to call the play function 50 times per second (because the song is 
      // designed at 50Hz). We only have to wait for VSYNC and call the play function
      // when the song is not stopped (still playing)
      cpct_waitVSYNC();

      // Check if the music is playing. When it is, do all the things the music
      // requires to be done every 1/50 secs.
      if (playing) {
         cpct_akp_musicPlay();   // Play next music 1/50 step.

         // Write a new number to the screen to see something while playing. 
         // The number will be 0 when music is playing, and 1 when it finishes.
         //  -> If some SFX is playing write the channel where it is playing
         
         // Check if there is an instrument plaing on channel A
         if (cpct_akp_SFXGetInstrument(AY_CHANNEL_A))
            cpct_drawCharM2(pvideomem, color, 'A'); // Write an 'A' because channel A is playing
         
         // Check if there is an instrument plaing on channel C
         else if (cpct_akp_SFXGetInstrument(AY_CHANNEL_C))
            cpct_drawCharM2(pvideomem, color, 'C'); // Write an 'C' because channel A is playing 
         
         // No SFX is playing on Channels A or C, write the number of times
         // this song has looped.
         else
            cpct_drawCharM2(pvideomem, color, '0' + cpct_akp_songLoopTimes);

         // Point to the start of the next character in video memory
         if (++pvideomem >= (u8*)0xC7D0) {
            pvideomem = CPCT_VMEM_START; // When we reach the end of the screen, we return..
            color ^= 1;                  // .. to the start, and change the colour
         }

         // Check if music has already ended (when looptimes is > 0)
         if (cpct_akp_songLoopTimes > 0)
            cpct_akp_musicInit(molusk_song); // Song has ended, start it again and set loop to 0
      }

      // Check keyboard to let the user play/stop the song with de Space Bar
      // and reproduce some sound effects with keys 1 and 0
      cpct_scanKeyboard_f();

      // When Space is released, stop / continue music
      if ( checkKeyEvent(Key_Space, &k_space) == K_RELEASED ) {
         // Only stop it when it was playing previously
         // No need to call "play" again when continuing, as the
         // change in "playing" status will make the program call "play"
         // again from the next cycle on
         if (playing)
            cpct_akp_stop();
         
         // Change it from playing to not playing and viceversa (0 to 1, 1 to 0)
         playing ^= 1;

      // Check if Key 0 has been released to reproduce a Sound effect on channel A
      } else if ( checkKeyEvent(Key_0, &k_0) == K_RELEASED ) {
         cpct_akp_SFXPlay(13, 15, 36, 20, 0, AY_CHANNEL_A);

      // Check if Key 1 has been released to reproduce a Sound effect on channel C
      } else if ( checkKeyEvent(Key_1, &k_1) == K_RELEASED ) 
         cpct_akp_SFXPlay(3, 15, 60, 0, 40, AY_CHANNEL_C);
   }
}