Hiya!
Im not new to programming but sometimes i can be really noobie so im sure this is probably really silly. I have an undecleared indentifier that only shows up in the main but is fine in the header and cpp files. I thought it might be an include loop but it doesnt seem to be. It can find the draw function but not its parameter. What have i forgotten?
Creature.h
#ifndef CREATURE_H
#define CREATURE_H
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <string>
using std::string;
class Creatures
{
private:
int xPos;
int yPos;;
ALLEGRO_BITMAP* sprite;
public:
Creatures(int x, int y, string s); // constructor
void draw(ALLEGRO_BITMAP* s);
};
#endif
Creature.cpp
#include "Creatures.h"
#include <iostream>
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
Creatures::Creatures(int x, int y, string s)
{
xPos = x;
yPos = y;
sprite = al_load_bitmap(s.c_str());
}
void Creatures::draw(ALLEGRO_BITMAP* s)
{
al_convert_mask_to_alpha(s, al_map_rgb(255,0,255));
al_draw_bitmap(s, getX(), getY(), 0);
}
Player.h (astroid and enemy are the same so i didnt include them)
#ifndef PLAYER_H
#define PLAYER_H
#include "Creatures.h"
class Player:public Creatures
{
private:
public:
Player(int x, int y, string s); //constructor
};
#endif
Player.cpp (astroid and enemy are the same so i didnt include them either)
#include "Player.h"
#include "Creatures.h"
Player::Player(int x, int y, string s):Creatures(x, y, s)
{
}
main
#include <iostream>
#include <conio.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include "Player.h"
#include "Enemy.h"
#include "Astroid.h"
int main()
{
//create objects
Player* player = new Player(50, 50, "Assets/playerSprite.bmp");
Enemy* enemy = new Enemy(100, 100, "Assets/enemySprite.bmp");
Astroid* astroid = new Astroid(200, 200, "Assets/astroidSprite.bmp");
while(!keys_pressed[KEY_ESCAPE])
{
player->draw(s); //errors are these 3 lines, s is an undeclared identifier
enemy->draw(s);
astroid->draw(s);
}
//destroy stuff
al_destroy_display(display);
getch();
return 0;
}
}
errors
Error 1 error C2065: 's' : undeclared identifier
I only included what i thought was relevant so tell me if you need more info.