Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - NiteStriker

Pages: [1]
1
Graphics / I can't draw items inside a linked list?
« on: June 27, 2010, 06:24:18 am »
Hi, thanks for replying  :)

I'll admit that I'm a bit of a beginner at C++ so I appreciate your commentary on how I could improve my code.

Here's the model that I used for each enemy constructor:

Code: [Select]

Enemy1(int x, int y):Enemy(x,y){
   getImage().LoadFromFile("src/Images/Enemy1.png");
   getSprite().SetImage(getImage());
}


The Image and sprite variables are contained in a super class. The functions that I used in this case return references to these variables.

The variables x and y simply set the coordinates (position) of the sprite.

2
Graphics / I can't draw items inside a linked list?
« on: June 26, 2010, 07:43:31 pm »
Before I begin, I would like to point out that I'm using:

-Ubuntu 9.10
-Eclipse (Helios) as my IDE
-GCC as my compiler
-GDB as my debugger

Ok so as the title of this thread suggests, I'm not able to draw items that are inside a linked list. In the game that I'm currently working on, I have an EnemyManager class. This class spawns enemies. It holds each enemy that it creates inside a linked list. I'm using the STL list (#include <list>) to accomplish this.

I put some of my code below to demonstrate how I'm doing this. The "enemies" variable is my linked list.

Code: [Select]

//draw all  enemies on the screen
void EnemyManager::draw(sf::RenderWindow & screen){

//first check to see if there are enemies to draw
if( enemies.size() > 0 ){

//create an iterator to traverse the list
list<Enemy>::iterator enemy;

//go through the list of enemies from start to the end
for(enemy = enemies.begin(); enemy != enemies.end(); enemy++){
//draw each enemy inside the list
screen.Draw((*enemy).getSprite());
}

  }
}




Whenever I traverse the items inside the list and use the draw function on each of them, they all come out as white squares. I know that there isn't a problem with the image loading because I'm able to declare a single enemy object outside of the EnemyManager class and draw it just fine.

I tried debugging it and here's what I get:
Code: [Select]
warning: can't find linker symbol for virtual table for `std::vector<sf::Color, std::allocator<sf::Color> >' value
warning: can't find linker symbol for virtual table for `std::_Vector_base<sf::Color, std::allocator<sf::Color> >::_Vector_impl' value


I'm not exactly sure of what the problem is but I've already included the Graphics library into the EnemyManager class. I'm pretty sure that the code should work since it worked correctly when using SDL.

Pages: [1]
anything