Bienvenido a Tecnohackers

Tecnohackers » Programacion » Area de Programacion » Programacion a Bajo Nivel. APIs, Hooking, ASM, C/C++, etc.
 » 

MataPatos[Allegro]



Autor Tema: MataPatos[Allegro]  (Leído 813 veces)

Desconectado P4|3L0

  • Asiduo
  • *
  • Mensajes: 75
  • TecnoHacker un nuevo proyecto.
    • http://www.tecnohacker.com
MataPatos[Allegro]
« en: Diciembre 29, 2009, 05:06:06 pm »
MataPatos

Les presento un nuevo "juego" es una de las pruebas que empece haciendo para empezar con el shooter solo son patos moviendose y tu con el cursor les vas matando. Lo hice antes de empezar con el shooter, el MataPatos no tiene niveles ni nada solo es un simple disparador con el que vas acabando con los patos, les dejo el source para que puedan desarrollarlo si quieren un poquito más y corregir algo. Se sale con ESC.




Código: You are not allowed to view links. Register or Login
#include <allegro.h> //It's my love

/* Timer stuff*/
volatile long speed_counter = 0; //A long integer which will store the value of the
//speed counter.

void increment_speed_counter() // A function to increment the speed counter
{
speed_counter=speed_counter+1;// This will just increment the speed counter by one.

}
END_OF_FUNCTION(increment_speed_counter);



int main()
{
    allegro_init();
    install_timer();
    install_mouse();
    install_keyboard();


LOCK_VARIABLE(speed_counter);
LOCK_FUNCTION(increment_speed_counter);//speed.
install_int_ex(increment_speed_counter, BPS_TO_TIMER(10));//Set our BPS

    set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT, 400, 170, 0, 0);


    BITMAP* mouse_image = load_bitmap("pointer.bmp", 0);
    BITMAP* monster = load_bitmap("monster.bmp", 0);
    BITMAP* monster2 = load_bitmap("monster.bmp", 0);
    BITMAP* monster3 = load_bitmap("monster.bmp", 0);
    BITMAP* monster4 = load_bitmap("monster.bmp", 0);
    BITMAP* buffer = create_bitmap(screen->w, screen->h);


int puntuacion=0;
int mx=0,my=90,mx2=-40,my2=70,mx3=-50,my3=45,mx4=-120,my4=10;
    while(!key[KEY_ESC])
    {

if(mouse_b&1){
 if(mouse_x > mx && mouse_x< mx+25 &&mouse_y >my&& mouse_y <my+40){
  textprintf_ex(buffer,font,20,20,makecol(255,255,255),-1,"Has matado al monstruo1");
  clear_bitmap(monster);
  puntuacion++;
 }

 else if(mouse_x > mx2 && mouse_x< mx2+25 &&mouse_y >my2&& mouse_y <my2+40){
  textprintf_ex(buffer,font,20,20,makecol(255,255,255),-1,"Has matado al monstruo2");
  clear_bitmap(monster2);
  puntuacion++;
}
 else if(mouse_x > mx3 && mouse_x< mx3+25 &&mouse_y >my3&& mouse_y <my3+40){
  textprintf_ex(buffer,font,20,20,makecol(255,255,255),-1,"Has matado al monstruo3");
  clear_bitmap(monster3);
  puntuacion++;
}
 else if(mouse_x > mx4 && mouse_x< mx4+25 &&mouse_y >my4&& mouse_y <my4+40){
  textprintf_ex(buffer,font,20,20,makecol(255,255,255),-1,"Has matado al monstruo4");
  clear_bitmap(monster4);
  puntuacion++;
}
}
while(speed_counter > 0)
{
mx=mx+4;
mx2=mx2+2;
mx3=mx3+6;
mx4=mx4+6;
    speed_counter --;
}

   clear_bitmap(monster);
   textprintf_ex(buffer,font,50,0,makecol(250,25,0),-1,"Tu puntuacion es: %i.ENHORABUENA.",puntuacion);

draw_sprite(buffer, monster,mx,my);
draw_sprite(buffer, monster2,mx2,my2);
draw_sprite(buffer, monster3,mx3,my3);
draw_sprite(buffer, monster4,mx4,my4);
draw_sprite(buffer, mouse_image, mouse_x, mouse_y);
textprintf_ex(buffer,font,mouse_x,(mouse_y-30),makecol(0,255,0),-1,"%i,%i",mouse_x,mouse_y);
textprintf_ex(buffer,font,0,0,makecol(250,25,0),-1,"%i",puntuacion);

blit(buffer, screen, 0, 0, 0, 0, screen->w, screen->h);
clear_bitmap(buffer);
    }

    return 0;

} END_OF_MAIN()

Descarga del Ejecutable(para quien no tenga Allegro):

You are not allowed to view links. Register or Login

Los dibujitos son una pasada :D



Tags:
Tags:

 


SMF 2.0.19 | SMF © 2016, Simple Machines
Paginas Afiliadas
Twitter - FaceBook - Daraxblog
Designed by Smf Personal