Null Purification.
Posted: Thu Feb 24, 2005 5:49 pm
For those of you who didn't know, I'm pretty much rewriting Null only this time I'm using good programming practices.
I just wanna show something off:
C'mon, look at that baby. God would be proud...
I just wanna show something off:
Code: Select all
class Player {
private:
float x, y;
float xvel, yvel;
uint16 width, height;
uint16 life;
bool run;
bool jump;
bool letgo; //keeps track if the user is holding down jump
bool canshoot; //keeps track if the user can shoot
bool dir;
bool dieing;
float jumptimer;
uint32 runtimer;
uint64 deathtimer;
public:
block Block[8];
buster Buster;
Player() {
x = 0;
y = 0;
xvel = 0;
yvel = 0;
jump = false;
letgo = true;
jumptimer = 0;
canshoot = true;
run = false;
runtimer = 0;
dieing = false;
width = 32;
height = 64;
life = 20;
}
float get_x() { return x; }
void set_x(int nx) { x = nx; }
float get_y() { return y; }
void set_y(int ny) { y = ny; }
float get_xvel() { return xvel; }
void set_xvel(float x) { xvel = x; }
float get_yvel() { return yvel; }
void set_yvel(float y) { yvel = y; }
uint16 get_life() { return life; }
void set_life(uint16 l) { life = l; }
uint16 get_width() { return width; }
void set_width(uint16 w) { width = w; }
uint16 get_height() { return height; }
void set_height(uint16 h) { height = h; }
bool get_run() { return run; }
void set_run(bool r) { run = r; }
bool get_jump() { return jump; }
void set_jump(bool j) { jump = j; }
bool get_letgo() { return letgo; }
void set_letgo(bool l) { letgo = l; }
bool get_canshoot() { return canshoot; }
void set_canshoot(bool c) { canshoot = c; }
bool get_dir() { return dir; }
void set_dir(bool d) { dir = d; }
bool set_dieing() { return dieing; }
void set_dieing(bool d) { dieing = d; }
float get_jumptimer() { return jumptimer; }
void set_jumptimer(float t) { jumptimer = t; }
uint32 get_runtimer() { return runtimer; }
void set_runtimer(uint32 t) { runtimer = t; }
uint64 get_deathtimer() { return deathtimer; }
void set_deathtimer(uint64 t) { deathtimer = t; }
void DrawPlayer() {
if(!dieing) {
draw_tr_quad((int)x + 16 - Gemini.scroll_x, (int)y + 16 - Gemini.scroll_y, 1, width, height, 1, 256-1, 256-140, 256-255);
draw_tr_quad((int)x + 16 - Gemini.scroll_x, (int)y + 16 - Gemini.scroll_y, 2, width - 4, height - 4, 1, 256-1, 256-1, 256-255);
}
}
void UpdateMisc() {
//simulate gravity (probably should be in jump function later)
yvel = yvel + Gravity;
//simulate friction
if(xvel < 0) xvel = xvel + Gravity;
if(xvel > 0) xvel = xvel - Gravity;
//sorry, can't jump while falling :D
if(yvel > 1) jump = true;
//Keep dude from moving too fast.
if( abs((int)xvel) > 3 )
(xvel < 0)? xvel = -3 : xvel = 3;
}
void Die();
friend int MoveHorizontal();
friend int MoveVertical();
void Bleed();
void Update();
void DrawLife();
};