Hey all,
Ok so i wasnt sure whether to put this in game programming or c++. So i put it here because it has little to do with the game more that im getting a linker error ever since i added my header file and implementation file. Here is the code....
Code:
// main
#include <allegro.h>
#include "game_essential.h"
int main(int argc, char *argv[])
{
init();
while(!key[KEY_ESC])
;
deinit();
return 0;
}
Code:
// implementation
#include "game_essential.h"
void init(void)
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
install_timer();
install_keyboard();
install_mouse();
}
void deinit(void)
{
clear_keybuf();
}
player::player(void)
{
x_speed = 0;
y_speed = 0;
hero = NULL;
}
level::level(void)
{
gravity = .7;
thrust = .9;
friction = .9333333;
}
int level::draw_scr(BITMAP *buf)
{
}
int level::set_floor(BITMAP *floor)
{
}
int level::set_background(BITMAP *bg)
{
}
// -------- player
int player::set_player(char *player_bmp)
{
hero = load_bitmap(player_bmp, NULL);
}
int player::draw_player(BITMAP *buffer)
{
draw_sprite(buffer, hero, x_real, y_real);
return 1;
}
int player::check_pos(void)
{
// finish...
}
int player::set_pos(level current)
{
}
Code:
// header
#include <allegro.h>
void init(void);
void deinit(void);
class level{
public:
level(void);
int draw_scr(BITMAP *buf);
int set_floor(BITMAP *floor);
int set_background(BITMAP *bg);
private:
BITMAP *buffer;
float gravity;
float thrust;
float friction;
};
class player{
public:
player(void);
int set_player(char *player_bmp); // set the player bitmap
int draw_player(BITMAP *buffer); // draw player to bitmap
int check_pos(void); // check collision ect
int set_pos(level current); // set the position
private:
BITMAP *hero; // our character
float power;
float x_speed;
float y_speed;
int x_real;
int y_real;
};
Im using dev c++ with the latest updates and allegro files. Please help! :/ Thank you!
-Mramazing