1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <stdio.h>
#include <math.h>
#include "c_enemy.h"
void c_enemy::Init()
{
direction=0;
x=450;
y=0;
}
void c_enemy::Draw()
{
if (direction==1) CGL_DrawSprite(x-scrollx,y-scrolly,spr_enemy);
else CGL_DrawMirroredSprite(x-scrollx,y-scrolly,spr_enemy);
}
void c_enemy::Handle()
{
int colorfeet,colorhead,colorright,colorleft,colorright2,colorleft2;
// Check Collision met het bitmap masker
colorfeet=CGL_GetPixel(x+32,y+62,bmp_mask);
colorright=CGL_GetPixel(x+64,y+32,bmp_mask);
colorleft=CGL_GetPixel(x,y+32,bmp_mask);
if (colorleft==COLOR_FLOOR) direction=1;
if (colorright==COLOR_FLOOR) direction=0;
if (colorfeet==COLOR_FLOOR) gravity=0.0;
else{
gravity+=0.1;
}
if (direction==1){
x++;
}
else{
x--;
}
y+=gravity;
CGL_DrawText(10,120,gamefont,"%d",direction);
}
|