//Character.h
#pragma once
#include <allegro.h>
#include "game.h"
class character{
public:
character ();
int a,aa;
int c;
void boundary ();
void superattacks();
void attacking ();
void intro ();
void walkR ();
void finishwalkR();
void walkL ();
void walking();
void dashing();
void solid ();
void healthbar ();
void enemyattack ();
BITMAP *background;
BITMAP *buffer;
BITMAP *walk [12];
BITMAP *walkl [12];
BITMAP *attack [10];
BITMAP *attackl [10];
BITMAP *superattack [10];
BITMAP *dash [10];
BITMAP *dashl[10];
BITMAP *buffer2;
BITMAP *face;
int eay,eax,eax2,eay2;
bool reset;
int startw,screenw,screenh;
int yy;
bool movebackground;
int moving;
int dir ;
int cl;
int x;
int y;
bool t ;
int i ;
bool stepcheck;
};
// character.cpp (its long)
#pragma once
#include <allegro.h>
#include "character.h"
#include "game.h"
void character::healthbar (){
BITMAP *face = load_bitmap ("F:\\sprites\\face.bmp",NULL);
circle (screen,500,50,40,makecol (0,184,239));
circle (screen,500,50,30,makecol (0,0,255));
line (screen,460,50,469,50,makecol (0,184,239));
line (screen,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (screen,470,30,makecol (0,255,0));
draw_sprite (screen,face,478,30);
}
character::character (){
eay =0;
eax =0;
eax2=0;
eay2=0;
face = load_bitmap ("F:\\sprites\\face.bmp",NULL);
character::buffer2 = create_bitmap (640,480);
reset = false;
startw = 0;
screenw = 640;
screenw = 480;
moving = 0;
dir = 0;
x = 10;
y = 325;
t = false;
i = 0;
a = -1;
aa = -1;
stepcheck = false;
movebackground = false;
// walking right sprites
background = load_bitmap ("F:\\sprites\\background2.bmp",NULL);
walk[0] = load_bitmap ("F:\\sprites\\walkR.bmp",NULL);
walk[1] = load_bitmap ("F:\\sprites\\walkR2.bmp",NULL);
walk[2] = load_bitmap ("F:\\sprites\\walkR3.bmp",NULL);
walk[3] = load_bitmap ("F:\\sprites\\walkR4.bmp",NULL);
walk[4] = load_bitmap ("F:\\sprites\\walkR5.bmp",NULL);
walk[5] = load_bitmap ("F:\\sprites\\walkR6.bmp",NULL);
walk[6] = load_bitmap ("F:\\sprites\\walkR7.bmp",NULL);
walk[7] = load_bitmap ("F:\\sprites\\walkR8.bmp",NULL);
walk[8] = load_bitmap ("F:\\sprites\\walkR9.bmp",NULL);
walk[9] = load_bitmap ("F:\\sprites\\walkR10.bmp",NULL);
walk[10] = load_bitmap ("F:\\sprites\\walkR11.bmp",NULL);
walk[11] =load_bitmap ("F:\\sprites\\standR.bmp",NULL);
c= -1;
cl = -1;
// walking left sprites
walkl[0] = load_bitmap ("F:\\sprites\\walkL.bmp",NULL);
walkl[1] = load_bitmap ("F:\\sprites\\walkL2.bmp",NULL);
walkl[2] = load_bitmap ("F:\\sprites\\walkL3.bmp",NULL);
walkl[3] = load_bitmap ("F:\\sprites\\walkL4.bmp",NULL);
walkl[4] = load_bitmap ("F:\\sprites\\walkL5.bmp",NULL);
walkl[5] = load_bitmap ("F:\\sprites\\walkL6.bmp",NULL);
walkl[6] = load_bitmap ("F:\\sprites\\walkL7.bmp",NULL);
walkl[7] = load_bitmap ("F:\\sprites\\walkL8.bmp",NULL);
walkl[8] = load_bitmap ("F:\\sprites\\walkL9.bmp",NULL);
walkl[9] = load_bitmap ("F:\\sprites\\walkL10.bmp",NULL);
walkl[10] = load_bitmap ("F:\\sprites\\walkL11.bmp",NULL);
walkl[11] = load_bitmap ("F:\\sprites\\standL.bmp",NULL);
// attacking right sprites
attack[0] = load_bitmap ("F:\\sprites\\attackR.bmp",NULL);
attack[1] = load_bitmap ("F:\\sprites\\attackR2.bmp",NULL);
attack[2] = load_bitmap ("F:\\sprites\\attackR3.bmp",NULL);
attack[3] = load_bitmap ("F:\\sprites\\attackR4.bmp",NULL);
attack[4] = load_bitmap ("F:\\sprites\\attackR5.bmp",NULL);
attack[5] = load_bitmap ("F:\\sprites\\attackR6.bmp",NULL);
attack[6] = load_bitmap ("F:\\sprites\\attackR7.bmp",NULL);
attack[7] = load_bitmap ("F:\\sprites\\attackR8.bmp",NULL);
attack[8] = load_bitmap ("F:\\sprites\\attackR9.bmp",NULL);
attack[9] = load_bitmap ("F:\\sprites\\attackR10.bmp",NULL);
attackl [0] = load_bitmap ("F:\\sprites\\attackL.bmp",NULL);
attackl [1] = load_bitmap ("F:\\sprites\\attackL2.bmp",NULL);
attackl [2] = load_bitmap ("F:\\sprites\\attackL3.bmp",NULL);
attackl [3] = load_bitmap ("F:\\sprites\\attackL4.bmp",NULL);
attackl [4] = load_bitmap ("F:\\sprites\\attackL5.bmp",NULL);
attackl [5] = load_bitmap ("F:\\sprites\\attackL6.bmp",NULL);
attackl [6] = load_bitmap ("F:\\sprites\\attackL7.bmp",NULL);
attackl [7] = load_bitmap ("F:\\sprites\\attackL8.bmp",NULL);
attackl [8] = load_bitmap ("F:\\sprites\\attackL9.bmp",NULL);
attackl [9] = load_bitmap ("F:\\sprites\\attackL10.bmp",NULL);
// super attack sprites
superattack [0] = load_bitmap ("F:\\sprites\\superattack1.bmp",NULL);
superattack [1] = load_bitmap ("F:\\sprites\\superattack2.bmp",NULL);
superattack [2] = load_bitmap ("F:\\sprites\\superattack3.bmp",NULL);
superattack [3] = load_bitmap ("F:\\sprites\\superattack4.bmp",NULL);
superattack [4] = load_bitmap ("F:\\sprites\\superattack5.bmp",NULL);
superattack [5] = load_bitmap ("F:\\sprites\\superattack6.bmp",NULL);
superattack [6] = load_bitmap ("F:\\sprites\\superattack7.bmp",NULL);
superattack [7] = load_bitmap ("F:\\sprites\\superattack8.bmp",NULL);
superattack [8] = load_bitmap ("F:\\sprites\\superattack9.bmp",NULL);
superattack [9] = load_bitmap ("F:\\sprites\\superattack10.bmp",NULL);
// dash sprite right
dash [0] = load_bitmap ("F:\\sprites\\dashR.bmp",NULL);
dash [1] = load_bitmap ("F:\\sprites\\dashR3.bmp",NULL);
dash [2] = load_bitmap ("F:\\sprites\\dashR4.bmp",NULL);
dash [3] = load_bitmap ("F:\\sprites\\dashR5.bmp",NULL);
dash [4] = load_bitmap ("F:\\sprites\\dashR6.bmp",NULL);
dash [5] = load_bitmap ("F:\\sprites\\dashR7.bmp",NULL);
dash [6] = load_bitmap ("F:\\sprites\\dashR8.bmp",NULL);
dash [7] = load_bitmap ("F:\\sprites\\dashR9.bmp",NULL);
dash [8] = load_bitmap ("F:\\sprites\\dashR10.bmp",NULL);
dash [9] = load_bitmap ("F:\\sprites\\dashR11.bmp",NULL);
//dash sprite left
dashl [0] = load_bitmap ("F:\\sprites\\dashL.bmp",NULL);
dashl [1] = load_bitmap ("F:\\sprites\\dashL3.bmp",NULL);
dashl [2] = load_bitmap ("F:\\sprites\\dashL4.bmp",NULL);
dashl [3] = load_bitmap ("F:\\sprites\\dashL5.bmp",NULL);
dashl [4] = load_bitmap ("F:\\sprites\\dashL6.bmp",NULL);
dashl [5] = load_bitmap ("F:\\sprites\\dashL7.bmp",NULL);
dashl [6] = load_bitmap ("F:\\sprites\\dashL8.bmp",NULL);
dashl [7] = load_bitmap ("F:\\sprites\\dashL9.bmp",NULL);
dashl [8] = load_bitmap ("F:\\sprites\\dashL10.bmp",NULL);
dashl [9] = load_bitmap ("F:\\sprites\\dashL11.bmp",NULL);
// creating the buffer
buffer = create_bitmap (640,480);
}
void character::solid(){
}
void character::boundary () {
if (x <= 0)
x = 0;
if (x >= 670)
x = 670;
if (y <= 0)
y = 0;
if (y >= 470)
y = 470;
}
void character::intro ()
{
i ++;
if (i == 11)
i =0;
if (x >= 630)
{t = true;
i = 0;}
if (x <= 0)
{t = false;
i = 0;}
if (t == false)
{ x += 5;
draw_sprite (buffer,walk[i],x,y);
}
if (t == true)
{ x -= 5;
draw_sprite (buffer,walkl[i],x,y);
}
blit (buffer,screen,0,0,0,0,640,480);
rest (50);
}
// beginnning of hte player walking (screen scrolling included.
void character::walking(){
if (key[KEY_RIGHT]){
bool t_f = false;
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
reset = true;
}
else{
startw = startw;
screenh = screenh;
screenw = screenw;}
int b = -1; // the counter
dir = 0; // DIRECTION IS RIGHT
while (b <5) {
if (x >= 300)
{
screenw += 10;
startw += 5;
}
else
x += 5;
b++;
c++;
if (c == 11)
c = 0;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walk [c],x,y);
blit (buffer,screen,0,0,0,0,640,480);
// end of stepping animation
}
if (!key [KEY_RIGHT]) {
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walk [11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of stop stepping - RIGHT
}
if (key [KEY_LEFT]){
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
reset = true;
}
else{
startw = startw;
screenh = screenh;
screenw = screenw;}
int b = -1; // the counter
dir = 180; // DIRECTION IS LEFT
while (b <5) {
if (x >= 300)
startw -= 10;
else
x -= 5;
if (startw <= 0 && x >= 300)
x = 299;
b++;
c++;
if (c ==11)
c= 0;
if (x <= 0)
x = 0;
if (startw <= 0)
startw = 0;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walkl [c],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of stepping animation -left
if (!key [KEY_LEFT]) {
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walkl [11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of stop stepping - LEFT
}
}
void character::attacking (){
if (key [KEY_X] && dir == 0){
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
reset = true;
}
else{
startw = startw;
screenh = screenh;
screenw = screenw;}
a = -1;
int d = -1;
y -= 12;
while (d < 9){
d++;
a ++;
if (a == 10)
a = 0 ;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,attack[a],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of attack animation while loop
y += 12;// lowering the player
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite(buffer,walk[11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
}
if (key [KEY_X]&&dir == 180){
a = -1;
int d = -1;
y -= 12;
while (d < 9){
d++;
a ++;
if (a == 10)
a = 0 ;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,attackl[a],x,y);
blit (buffer,screen,0,0,0,0,640,480);
rest (80);
}
y += 12;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite(buffer,walkl[11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
}
}
void character::superattacks(){
if (key [KEY_Z]){
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
reset = true;
}
else{
startw = startw;
screenh = screenh;
screenw = screenw;}
int d = 4;
y -= 60;
while (key[KEY_Z])
{
aa ++;
if (aa == 4)
aa = 0;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,superattack[aa],x,y);
blit (buffer,screen,0,0,0,0,640,480);
}
int yy = 0;
while (d <9){
d ++;
y += 5;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,superattack[d],x,y);
blit (buffer,screen,0,0,0,0,640,480);
rest (80);
}
y += 35;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite(buffer,walk[11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
}
}
void character::dashing () {
if (key[KEY_D]){
dir = 0;
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
reset = true;
}
else{
startw = startw;
screenh = screenh;
screenw = screenw;}
while (key[KEY_D]){
if (x >= 300)
{
screenw += 10;
startw += 10;
}
else
x += 10;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,dash [1],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end dashing right while loop
int count = 1;
while (count < 9) {
count ++;
startw += 10 - count;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,dash [count],x,y - 8);
blit (buffer,screen,0,0,0,0,640,480);
} // end of dash landing while loop
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walk [11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end if statement - pressing d, dir = 0
// beginning of dashing left
if (key[KEY_A])
{
if (reset == false){
screenh = 640;
screenw = 480;
startw = 0;
dir = 180;
reset = true;
}
else{
dir = 180;
startw = startw;
screenh = screenh;
screenw = screenw;}
while (key[KEY_A]){
if (x >= 300)
startw -= 10;
else
x -= 10;
if (startw <= 0 && x >= 300)
x = 299;
rest (80);
if (x <= 0)
x = 0;
if (startw <= 0)
startw = 0;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,dashl [1],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of while dash loop - LEFT
int count = 1;
while (count < 9){
count ++;
startw -= 10 - count;
if (startw <= 0)
startw = 0;
rest (80);
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,dashl [count],x,y -8);
blit (buffer,screen,0,0,0,0,640,480);
} // end of landing loop - LEFT
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -eay,469 + eax,50 - eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
draw_sprite (buffer,walkl [11],x,y);
blit (buffer,screen,0,0,0,0,640,480);
} // end of if dash if statement - LEFT
}// end of void dashing
void character::enemyattack () {
if (key [KEY_T]) {
eay += 5;
blit (background,buffer,startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,255,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460-21,50,500,50,makecol (0,0,0));
line (buffer,460 -21 + eax,50 -eay,500 + eax2,50 - eay2,makecol (0,0,0));
floodfill (buffer,465,49,makecol (255,0,255));
//floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,face,478,30);
blit (buffer,screen,0,0,0,0,640,480);
rest (200);
// while (key [KEY_T]) {
// if (eay < 20)
// eay += 5;
// else
// eay += 10;
// if (eay % 5 == 0)
// eax += 1;
//
// blit (background,buffer,startw,0,0,0,640,480);
//circle (buffer,500,50,40,makecol (0,184,239));
//circle (buffer,500,50,30,makecol (0,0,255));
//line (buffer,460,50,469,50,makecol (0,184,239));
//line (buffer,460+ eax,50 -eay,469 + eax2,50 - eay2,makecol (0,184,239));
////floodfill (buffer,500,50,makecol (0,0,255));
////floodfill (buffer,470,30,makecol (0,255,0));
//draw_sprite (buffer,face,478,30);
//blit (buffer,screen,0,0,0,0,640,480);
//
//
// }
}
}
//enemy.h (just started it)
#pragma once
#include <allegro.h>
#include "character.h"
#include "game.h"
class enemy {
public:
enemy ();
BITMAP *combo [35];
BITMAP *combol [35];
BITMAP *buffer;
void moving (character &xx);
//int distance;
int x;
int y;
};
//enemy.cpp (just started)
#pragma once
#include <allegro.h>
#include "character.h"
#include "game.h"
#include "enemy.h"
enemy::enemy () {
combo [0] = load_bitmap ("F:\\enemysprites\\redcomboR.bmp",NULL);
combo [1] = load_bitmap ("F:\\enemysprites\\redcomboR2.bmp",NULL);
combo [2] = load_bitmap ("F:\\enemysprites\\redcomboR3.bmp",NULL);
combo [3] = load_bitmap ("F:\\enemysprites\\redcomboR4.bmp",NULL);
combo [4] = load_bitmap ("F:\\enemysprites\\redcomboR5.bmp",NULL);
combo [5] = load_bitmap ("F:\\enemysprites\\redcomboR6.bmp",NULL);
combo [6] = load_bitmap ("F:\\enemysprites\\redcomboR7.bmp",NULL);
combo [7] = load_bitmap ("F:\\enemysprites\\redcomboR8.bmp",NULL);
combo [8] = load_bitmap ("F:\\enemysprites\\redcomboR9.bmp",NULL);
combo [9] = load_bitmap ("F:\\enemysprites\\redcomboR10.bmp",NULL);
combo [10] = load_bitmap ("F:\\enemysprites\\redcomboR11.bmp",NULL);
combo [11] = load_bitmap ("F:\\enemysprites\\redcomboR12.bmp",NULL);
combo [12] = load_bitmap ("F:\\enemysprites\\redcomboR13.bmp",NULL);
combo [13] = load_bitmap ("F:\\enemysprites\\redcomboR14.bmp",NULL);
combo [14] = load_bitmap ("F:\\enemysprites\\redcomboR15.bmp",NULL);
combo [15] = load_bitmap ("F:\\enemysprites\\redcomboR16.bmp",NULL);
combo [16] = load_bitmap ("F:\\enemysprites\\redcomboR17.bmp",NULL);
combo [17] = load_bitmap ("F:\\enemysprites\\redcomboR18.bmp",NULL);
combo [18] = load_bitmap ("F:\\enemysprites\\redcomboR19.bmp",NULL);
combo [19] = load_bitmap ("F:\\enemysprites\\redcomboR20.bmp",NULL);
combo [20] = load_bitmap ("F:\\enemysprites\\redcomboR21.bmp",NULL);
combo [21] = load_bitmap ("F:\\enemysprites\\redcomboR22.bmp",NULL);
combo [22] = load_bitmap ("F:\\enemysprites\\redcomboR23.bmp",NULL);
combo [23] = load_bitmap ("F:\\enemysprites\\redcomboR24.bmp",NULL);
combo [24] = load_bitmap ("F:\\enemysprites\\redcomboR25.bmp",NULL);
combo [25] = load_bitmap ("F:\\enemysprites\\redcomboR26.bmp",NULL);
combo [26] = load_bitmap ("F:\\enemysprites\\redcomboR27.bmp",NULL);
combo [27] = load_bitmap ("F:\\enemysprites\\redcomboR28.bmp",NULL);
combo [28] = load_bitmap ("F:\\enemysprites\\redcomboR29.bmp",NULL);
combo [29] = load_bitmap ("F:\\enemysprites\\redcomboR30.bmp",NULL);
combo [30] = load_bitmap ("F:\\enemysprites\\redcomboR31.bmp",NULL);
combo [31] = load_bitmap ("F:\\enemysprites\\redcomboR32.bmp",NULL);
combo [32] = load_bitmap ("F:\\enemysprites\\redcomboR33.bmp",NULL);
combo [33] = load_bitmap ("F:\\enemysprites\\redcomboR34.bmp",NULL);
combo [34] = load_bitmap ("F:\\enemysprites\\redcomboR35.bmp",NULL);
// facing left combo
combol [0] = load_bitmap ("F:enemysprites\\redcomboL.bmp",NULL);
combol [1] = load_bitmap ("F:\\enemysprites\\redcomboL2.bmp",NULL);
combol [2] = load_bitmap ("F:\\enemysprites\\redcomboL3.bmp",NULL);
combol [3] = load_bitmap ("F:\\enemysprites\\redcomboL4.bmp",NULL);
combol [4] = load_bitmap ("F:\\enemysprites\\redcomboL5.bmp",NULL);
combol [5] = load_bitmap ("F:\\enemysprites\\redcomboL6.bmp",NULL);
combol [6] = load_bitmap ("F:\\enemysprites\\redcomboL7.bmp",NULL);
combol [7] = load_bitmap ("F:\\enemysprites\\redcomboL8.bmp",NULL);
combol [8] = load_bitmap ("F:\\enemysprites\\redcomboL9.bmp",NULL);
combol [9] = load_bitmap ("F:\\enemysprites\\redcomboL10.bmp",NULL);
combol [10] = load_bitmap ("F:\\enemysprites\\redcomboL11.bmp",NULL);
combol [11] = load_bitmap ("F:\\enemysprites\\redcomboL12.bmp",NULL);
combol [12] = load_bitmap ("F:\\enemysprites\\redcomboL13.bmp",NULL);
combol [13] = load_bitmap ("F:\\enemysprites\\redcomboL14.bmp",NULL);
combol [14] = load_bitmap ("F:\\enemysprites\\redcomboL15.bmp",NULL);
combol [15] = load_bitmap ("F:\\enemysprites\\redcomboL16.bmp",NULL);
combol [16] = load_bitmap ("F:\\enemysprites\\redcomboL17.bmp",NULL);
combol [17] = load_bitmap ("F:\\enemysprites\\redcomboL18.bmp",NULL);
combol [18] = load_bitmap ("F:\\enemysprites\\redcomboL19.bmp",NULL);
combol [19] = load_bitmap ("F:\\enemysprites\\redcomboL20.bmp",NULL);
combol [20] = load_bitmap ("F:\\enemysprites\\redcomboL21.bmp",NULL);
combol [21] = load_bitmap ("F:\\enemysprites\\redcomboL22.bmp",NULL);
combol [22] = load_bitmap ("F:\\enemysprites\\redcomboL23.bmp",NULL);
combol [23] = load_bitmap ("F:\\enemysprites\\redcomboL24.bmp",NULL);
combol [24] = load_bitmap ("F:\\enemysprites\\redcomboL25.bmp",NULL);
combol [25] = load_bitmap ("F:\\enemysprites\\redcomboL26.bmp",NULL);
combol [26] = load_bitmap ("F:\\enemysprites\\redcomboL27.bmp",NULL);
combol [27] = load_bitmap ("F:\\enemysprites\\redcomboL28.bmp",NULL);
combol [28] = load_bitmap ("F:\\enemysprites\\redcomboL29.bmp",NULL);
combol [29] = load_bitmap ("F:\\enemysprites\\redcomboL30.bmp",NULL);
combol [30] = load_bitmap ("F:\\enemysprites\\redcomboL31.bmp",NULL);
combol [31] = load_bitmap ("F:\\enemysprites\\redcomboL32.bmp",NULL);
combol [32] = load_bitmap ("F:\\enemysprites\\redcomboL33.bmp",NULL);
combol [33] = load_bitmap ("F:\\enemysprites\\redcomboL34.bmp",NULL);
combol [34] = load_bitmap ("F:\\enemysprites\\redcomboL35.bmp",NULL);
buffer = create_bitmap (640,480);
x = 600;
y = 325;
}
void enemy::moving (character &xx) {
//draw_sprite (buffer,combol[34],x,y);
int distanceE;
int distanceC;
int counter = -1;
distanceE = x - xx.x + xx.startw;
distanceC = xx.x - x;
if (xx.x >= 299){ //|| xx.x >= x && distanceC <= 20
while (counter <34){
distanceE = x - xx.x + xx.startw;
distanceC = xx.x - x;
counter += 1;
blit (xx.background,buffer,xx.startw,0,0,0,640,480);
circle (buffer,500,50,40,makecol (0,184,239));
circle (buffer,500,50,30,makecol (0,0,255));
line (buffer,460,50,469,50,makecol (0,184,239));
line (buffer,460,50 -xx.eay,469 + xx.eax,50 - xx.eay,makecol (0,184,239));
//floodfill (buffer,500,50,makecol (0,0,255));
floodfill (buffer,470,30,makecol (0,255,0));
draw_sprite (buffer,xx.face,478,30);
draw_sprite (buffer,combol [counter],x,y);
blit (buffer,screen,0,0,0,0,640,480);
}
}
}
// Main.cpp
#pragma once
#include <allegro.h>
#include <iostream>
#include "character.h"
#include "game.h"
#include "enemy.h"
using namespace std;
#define screenw 640
#define screenh 400
volatile long counter = 0;
void IncCtr() {counter ++ ;}
BITMAP *menu [4];
BITMAP *menucover;
void menus ();
int main ()
{
allegro_init ();
install_keyboard ();
install_mouse ();
set_color_depth (24);
set_gfx_mode (GFX_AUTODETECT_WINDOWED,screenw,screenh,0,0);
LOCK_VARIABLE (counter);
LOCK_FUNCTION (IncCtr);
install_int_ex (IncCtr,BPS_TO_TIMER (90));
bool quit = false;
character peter;
enemy akeel;
BITMAP *buffer = create_bitmap (640,480);
rectfill (screen,0,0,640,480,makecol(0,0,0));
blit (peter.background,screen,0,0,0,0,640,480);
//arc (screen,300,50,70,0,20,makecol (0,0,0));
draw_sprite(screen,peter.walk[11],peter.x,peter.y);
draw_sprite(screen,akeel.combol [34],akeel.x,akeel.y);
//BITMAP *background = load_bitmap ("F:\\sprites\\Map1.bmp",NULL);
//blit (background,buffer,0,0,0,0,640,480);
//draw_sprite(buffer,peter.walk[11],peter.x,peter.y);
//blit (buffer,screen,0,0,0,0,640,480);
peter.healthbar();
while (quit == false)
{
while (counter > 0)
{
clear_keybuf();
if (key[KEY_ESC]){
quit = true;
counter = 3;}
//rectfill(buffer,0,0,640,480,makecol (0,0,0));
//peter.intro();
menus ();
peter.walking();
peter.dashing();
peter.attacking();
peter.superattacks();
peter.enemyattack();
akeel.moving (peter);
if (key[KEY_ESC]){
counter = 5;
quit = true;}
counter -= 1;
}
}
return 0;
}
END_OF_MAIN();
void menus () {
if (key[KEY_M]){
menu [0] = load_bitmap ("F:\\sprites\\menu.bmp",NULL);
menu [1] = load_bitmap ("F:\\sprites\\menu2.bmp",NULL);
menu [2] = load_bitmap ("F:\\sprites\\menu3.bmp",NULL);
menu [3] = load_bitmap ("F:\\sprites\\menu4.bmp",NULL);
menucover = load_bitmap ("F:\\sprites\\menucover.bmp",NULL);
blit (menucover,screen,0,0,0,0,640,480);
masked_blit (menu[0],screen,0,0,0,0,640,480);
int i = 0;
while (!key[KEY_P]) {
if (key[KEY_DOWN]) {
rest (200);
i += 1;
if (i >=3)
i = 3;
blit (menucover,screen,0,0,0,0,640,480);
masked_blit (menu[i],screen,0,0,0,0,640,480);
}
if (key[KEY_UP]) {
rest (200);
i -= 1;
if (i <= 0)
i = 0;
blit (menucover,screen,0,0,0,0,640,480);
masked_blit (menu [i],screen,0,0,0,0,640,480);
}
}
}
} |