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 - ExcessNeo

Pages: [1] 2
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
General discussions / Need help to test the new joystick code
« on: December 06, 2007, 03:21:31 am »
I'll dig up my Saitek X45 and test it out after this weekend.  :)

3
Graphics / Re: reason for unsigned int
« on: September 28, 2007, 12:27:53 pm »
Quote from: "Pwndja"
I was using this function with string.size() which returns an unsigned int, and so I used unsigned int to stop linker warnings. but i forgot to change the unsigned int after i had put solid numbers in the for loop.


Actually, that is incorrect. The method string.size() returns an
Code: [Select]
std::string::size_type

It is better to use that rather than an unsigned integer when operating with string.size().

You can simply typedef it shorter if you so wish.

4
General / Vs2005 SP1 Deployment Problem
« on: September 07, 2007, 11:17:13 pm »
Or in Project Properties -> C/C++ -> Code generation; change the Runtime library to one of the non DLL settings for the right build type (Debug (Multi-Threaded Debug (/MTd)) and Release (Multi-Threaded (/MT)).

That saves the including of a redistribution, but increases the size of your build.

5
Graphics / Problem with image loading!
« on: September 04, 2007, 06:00:57 pm »
Quote from: "Mindiell"
I don't think this is the good solution. What you do is having a 100x100 image and taking only the first 50x50 part...

My first question is :
- Why are you using the same sprite to draw 2 images ?


I was going to have questioned his methods but I thought I'd rather provide a working and very valid solution to his problem, in the style of his code to save arguement.

Although I do agree with you that the simple solution is to create a new Sprite for each image.

6
Graphics / Problem with image loading!
« on: September 04, 2007, 05:37:41 pm »
No problem mate.

7
Graphics / Problem with image loading!
« on: September 04, 2007, 05:30:54 pm »
Ok, this is the method that should work.

SetSubRect(const sfIntRect& SubRect)

Code: [Select]

sfImage image1;
sfImage image2;
   
image1.LoadFromFile("image1.bmp");
image2.LoadFromFile("image1.bmp");
   
sfSprite sprite(image1);

sfIntRect SubRect;
SubRect.Left = 0;
SubRect.Top = 0;
SubRect.Bottom = 50;
SubRect.Right = 50;

sprite.SetSubRect(SubRect);
sprite.SetImage(image2);

8
Graphics / Problem with image loading!
« on: September 04, 2007, 05:07:41 pm »
You could try the Scale(float Factor) method in the sfSprite class.

Like so
Code: [Select]

sfImage image1;
sfImage image2;
   
image1.LoadFromFile("image1.bmp");
image2.LoadFromFile("image1.bmp");
   
sfSprite sprite(image1);

sprite.Scale(0.5f);
sprite.SetImage(image2);

9
General discussions / Re: namespaces -- my 5 cent
« on: August 21, 2007, 12:49:36 pm »
Quote from: "lordolin"
Every major C++ API out there has its own namespaces and if u want this to become the next SDL maybe even used in commercial titles this is absolutely essential.

I may not have used SDL for awhile but last I remembered there was no namespaces needed to be used on my side. When I last used DirectX I also don't remember a namespace required to be used, and from what OpenGL code I have seen there also is not a single namespace declaration required from the API.

Bad arguement.
 
Quote
Of course, there are real, actual, tangible reasons for it:
1. write less if you use "using namespace xyz"


Hold on.....you call yourself a professional developer, yet you recommend people to do "using namespace namespace-name"? :shock:

10
General / Ubuntu AMD64 Compatible?
« on: August 15, 2007, 02:39:25 pm »
Glad to help.

11
General / Ubuntu AMD64 Compatible?
« on: August 14, 2007, 11:55:30 pm »
Built and now working on Ubuntu 64-bit.

If you want the lib files I can email a .tar.gz file with the built ones to you Laurent.

12
General / Ubuntu AMD64 Compatible?
« on: August 14, 2007, 04:06:45 pm »
I'll give it a go when I'm back on my main PC (Still have Ubuntu 64 on that one) after work tonight. Should be easier for me to install Ubuntu 32-bit on that computer if all things don't go well.

13
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

14
General discussions / unicode support
« on: August 14, 2007, 05:32:41 am »
If you mean by taking input while running then it appears so:

From: Window Events Tutorial.
Quote
Text events (TextEntered)

    * Event.Text.Unicode contains the UTF-16 code of the character that has been entered


Event.Text is part of the sfEvent Class.

15
General discussions / this looks interesting
« on: August 14, 2007, 05:15:42 am »
I found it on GameDev too, couldn't click the link fast enough :-p

It's a shame that it's not compatible with 64-bit Linux (had fun installing a 32-bit with no CD-RW drive on my current machine) but my experience of SFML so far has been nothing short of fantastic, well worth the set-up time I went through.

Pages: [1] 2