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.


Topics - ExcessNeo

Pages: [1]
1
Graphics / Strange Sprite Activities when using STL data structures
« on: December 13, 2007, 06:27:51 pm »
I have written a block class to use with a vector data structure to represent blocks in a game of breakout. My problem is, if I create a single instance of the block the image displays fine, however if I stick it in a vector it renders the block completely white.

Here is the code from main.cpp, I have commented out the method that displays correctly.

Code: [Select]
// main.cpp
#include <SFML/Graphics.hpp>
#include "Paddle.h"
#include "Ball.h"
#include "Brick.h"
#include "Vector2.h"
#include <vector>

typedef std::vector<Breakout::Brick>::iterator Brick_it;

int main()
{
sf::RenderWindow Window(sf::VideoMode(1024, 768, 32), "Break Out", sf::Window::Fixed, 4);

Breakout::Paddle player("./data/player.png", (Window.GetWidth() / 2.0f));
Breakout::Ball ball("./data/ball.png");

std::vector<Breakout::Brick> bricks;
Vector2 pos(0.0f, 0.0f);
for(int i = 0; i < 8; i++)
{
Breakout::Brick brick("./data/block.tga", pos);
bricks.push_back(brick);
pos.x +=101;
}

// Breakout::Brick brick("./data/block.tga", Vector2(500.0f, 500.0f));

bool Running = true;
while(Running)
{
sf::Event Event;
while(Window.GetEvent(Event))
{
if(Event.Type == sf::Event::Close)
Running = false;

if(Event.Type == sf::Event::KeyPressed)
{
if(Event.Key.Code == sf::Key::Escape)
Running = false;
}
}
float deltatime = Window.GetFrameTime();

// Handle player movements
if(Window.GetInput().IsKeyDown(sf::Key::Left))
player.move(deltatime, -300.0f);
if(Window.GetInput().IsKeyDown(sf::Key::Right))
player.move(deltatime, 300.0f);

ball.move(deltatime, player);

// This is where bricks are iterated through and drawn
Brick_it i = bricks.begin();
while(i != bricks.end())
{
if(i->destroy(ball) == false)
{
Window.Draw(i->GetSprite());
i++;
}
else
i = bricks.erase(i);
}

Window.Draw(player.getSprite());
Window.Draw(ball.GetSprite());
// Window.Draw(brick.GetSprite());
Window.Display();
}
return EXIT_SUCCESS;
}


I have a feeling it may be to do with the iterator, but to erase from data structures properly and effectively I should be able to use iterators.

If you need to see my class' I will post them but all my GetSprite function does is returns a reference to a sf::Sprite member called m_Sprite.

2
Feature requests / More Joystick Axis/Buttons
« on: August 14, 2007, 05:49:53 am »
A suggestion for a future release.

    Support for a higher range of Buttons for those with more advanced joysticks
    Support for a higher number of Axis for those with more advanced joysticks/joy pads with two analogue sticks


Keep up the good work  :D

3
General / Ubuntu AMD64 Compatible?
« on: August 13, 2007, 10:22:01 pm »
I've attempted to install on Ubuntu 7.04 AMD64 and I can't seem to get anything to build.

Here is what i type into the Bash prompt and the subsequent output from g++:
Quote
$ g++ -o test test.o -lsfml-system
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../lib64/libsfml-system.so when searching for -lsfml-system
/usr/bin/ld: skipping incompatible /usr/lib/../lib64/libsfml-system.so when searching for -lsfml-system
/usr/bin/ld: skipping incompatible /usr/bin/../lib/libsfml-system.so when searching for -lsfml-system
/usr/bin/ld: skipping incompatible /usr/lib64/libsfml-system.so when searching for -lsfml-system
/usr/bin/ld: skipping incompatible /usr/lib/libsfml-system.so when searching for -lsfml-system
/usr/bin/ld: cannot find -lsfml-system
collect2: ld returned 1 exit status


I also tried out with CodeBlocks but it kept telling me that the calls to functions were undefined yet I setup as the instructions said and copied and pasted the Clock.cpp code from the tutorial on the main website.

Edit: my temporary workaround has been to switch to 32-bit Ubuntu, would be nice to see a future release that supports 64-bit Linux, but its still a fantastic start.

Pages: [1]