Ejemplo n.º 1
0
/* 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;
      }

   }
}
Ejemplo n.º 2
0
/*MENU*/
int menu(){
   u8* memptr;
   int init = 50;
   int pushed =0;
   int cont =0;
   cpct_clearScreen(0);

   memptr = cpct_getScreenPtr(VMEM,10,10);
   cpct_drawSprite(portada1,memptr,60,60);

   //Opciones
   memptr = cpct_getScreenPtr(VMEM,20,90);
   cpct_drawStringM0("Nueva Partida",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,110);
   cpct_drawStringM0("Creditos",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,130);
   cpct_drawStringM0("Constroles",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,150);
   cpct_drawStringM0("Salir",memptr,1,0);

    /*memptr = cpct_getScreenPtr(VMEM,18,180);
   cpct_drawStringM0("Pulsa Intro",memptr,4,5);*/

   //Indicador
   while(1){

      cpct_scanKeyboard();
      if(cpct_isKeyPressed(Key_CursorDown) && cont > 150){
        cpct_drawSolidBox(memptr, 0, 2, 8);
        if(pushed<3) pushed ++;
        cont =0;
      }
      if(cpct_isKeyPressed(Key_CursorUp) && cont > 150){
        cpct_drawSolidBox(memptr, 0, 2, 8);
        if(pushed>0) pushed --;
        cont = 0;
      }

      switch (pushed){
        case 0: init = 90;break;
        case 1: init = 110;break;
        case 2: init = 130;break;
        case 3: init = 150;break;
      }
      memptr = cpct_getScreenPtr(VMEM,15,init);
      cpct_drawSprite(marcador,memptr, 2, 8);
      if(cpct_isKeyPressed(Key_Space)){
        switch (pushed){
        case 0: return 1;break;
        case 1: return 2;break;
        case 2: return 3;break;
        case 3: return 0;break;
      }
      }
      cont++;
   }
}
Ejemplo n.º 3
0
/* 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;
      }

   }
}
Ejemplo n.º 4
0
//
// MAIN PROGRAM:
//   Do not disable firmware in this example, as printf makes use of it through putchar
//
void main(void) {
   u8 i;
   
   // Clear Screen filling it up with 0's
   cpct_clearScreen(0);

   // Print out a table with the firmware colours and their equivalent
   // Hardware colour values using cpct_getHWColour

   // We use Firmware Screen Character Commands to change colour on screen.
   // Printing \0XX is equivalent to printing the character XX (in octal).
   // Character 15 (017 in octal) does the PEN command, and uses immediate next
   // character as the parameter for PEN. Then, \017\003 is equivalent to PEN 3.
   //
   printf("        \017\003Hardware Colour values\017\002          ");
   printf("This example shows the  equivalence between firmware co-");
   printf("lour  values  and harwdware  colour values. \017\003CPCtelera\017\002's ");
   printf("functions that change colours use hardware ones.\n\r\n\r");
   printf("   \017\003==================================\n\r");
   printf("   || \017\002FIRM -- HARD \017\003|| \017\002FIRM -- HARD \017\003||\n\r");
   printf("   ==================================\n\r");
   for (i=0; i < 13; ++i) {
      printf("   \017\003||  \017\001%2d  \017\003--  \017\001%2d\017\003  ",       i, cpct_getHWColour(i));
      printf("\017\003||  \017\001%2d  \017\003--  \017\001%2d\017\003  ||\n\r", i+13, cpct_getHWColour(i+13));
   }
   printf("   ==================================\n\r");

   // Loop forever
   while (1);
}
Ejemplo n.º 5
0
////////////////////////////////////////////////////////////////////////////////
// Initializes elements of the screen on the initialization of a new game
//
void initializeGameScreen(u16 hiscore) {
   u8* pscr;   // Pointer to the screen location where we want to draw
   u8  c;      // Colour pattern to draw
   u8  str[6]; // Score
   
   // Clear the screen
   cpct_clearScreen(0);

   //
   // Draw backgrounds and Hi-Score
   //
   c = cpct_px2byteM0(8,8);  // Colour pattern 8-8 (black-black)
   
   // Draw black background for scoreboard
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 54,   0);  
   cpct_drawSolidBox(pscr, c, 26, 200);

   // Draw "HI" string 
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60,  16);   
   cpct_drawStringM0("HI", pscr, 3, 8);

   // Draw HI-Score
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60,  24);
   sprintf(str, "%5u", hiscore);
   cpct_drawStringM0(str, pscr, 15, 8);

   // Draw Credits
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60, 172);
   cpct_drawSprite(G_credits, pscr, 20, 27);

   // Draw tiled frame around playing area
   drawFrame(CPCT_VMEM_START, 0);
}
Ejemplo n.º 6
0
//
// MAIN LOOP
//
void main(void) {
   // Initialization
   cpct_disableFirmware();
   cpct_setVideoMode(0);

   // Main loop: filling the screen using the 4 different basic 
   //            aligned functions in turns.
   while(1) {
      u8  i;   // Loop counters
      u16 w;

      // 4 iterations of filling up the screen out of tiles using
      // the 4 different tile-drawing functions
      for (i=0; i < 6; i++) {
         // First, clear the screen and wait for a while
         cpct_clearScreen(0);
         for (w=0; w < WAITCLEARED; w++);

         // Then, fill up the screen with the next tile-drawing function and wait another while
         fillupScreen(&(tiles[i]));
         for (w=0; w < WAITPAINTED; w++);
      }
   }
}
Ejemplo n.º 7
0
/*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;
      }

   }
}
Ejemplo n.º 8
0
/*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;
      } 
      

   }
}