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

Pages: [1] 2
1
Graphics / Setting a view's position?
« on: January 17, 2012, 05:26:04 am »
Hey thanks, I'll try that!

EDIT: Tested, it works just as intended.

2
Graphics / Setting a view's position?
« on: January 17, 2012, 04:19:18 am »
Is there a way that I could change a view's position without using .Move()?  I'd like to directly just set the position(in world coordinates) if that's possible.  Perhaps I'm missing some obvious reason why this can't be done though.

Thanks.

3
Graphics / Manipulating a RenderWindow's view?
« on: January 16, 2012, 01:14:58 am »
Actually making it global would probably work better as then I could access it in functions that don't have "App" as a parameter.

4
Graphics / Manipulating a RenderWindow's view?
« on: January 16, 2012, 12:26:27 am »
Quote from: "TheEnigmist"
PS: i'm not using SFML, i will start use it tomorrow maybe.
Btw, can you use a global view? Or give a reference of that view to your function?


Not sure what you mean by global view(EDIT:Oh, I think you mean making it a global variable.  Thanks, I've thought of that too, but I'd like to try and get my current situation to work :) ), and yes I could probably give the view as a reference to the function but I'd like to keep it simple.  Since the RenderWindow "App" is already a parameter, I'd rather be able to use one of it's methods or properties to reach the view.

Also, here's some example code.  This is all in my main.cpp file for simplification:

Code: [Select]
App.GetView().Move(3,4);

I'd like this to work, but I get an error that says the object has type qualifiers that prevent a match and that there are too many arguments in the function call, yet if I use the view directly and say gameView.Move(3, 4), it will work.

Code: [Select]
const sf::View& view = App.GetView();
view.Move(3,4);


I tried this too, didn't really expect it to work...which it didn't.

5
Graphics / Manipulating a RenderWindow's view?
« on: January 15, 2012, 11:35:38 pm »
Hello there.  I have a RenderWindow called "App" and set it's view to a new one I created called gameView.  I can manipulate this view from my main cpp file because that's where I created it but I want to access the view out of it's scope so I can use the view's move method.  I have a function that takes in the reference of "App", and I can manipulate that, but I can't seem to get the view from it.  I assume I have to use App.GetView() but it doesn't seem to work.  I can say const sf::View var = App.GetView() but I can't call var.Move or manipulate it in any way.  App.GetView() gives you a constant so that might have to do with it.  How do I use it correctly?

PS I'm using SFML 2

6
General / Library compatibility with boost multi array?
« on: November 18, 2011, 02:50:36 am »
Hello there.  I've recently added boost multi arrays to my project but there is a problem.  Boost multi array apparently has some sort of problem iterating in VS10 so resizing them isn't working.  After some googling, I have found that adding "_ITERATOR_DEBUG_LEVEL=0" to the preprocessor definitions.  This seemed to fix that error but then I get an "unhandled exception*blahblahmemorylocations* at msvcr100d.dll" at an earlier spot that only happens when I try to declare things from the SFML library.
EDIT:I can create a texture however when I try to do
Code: [Select]
if (!currentTexture.LoadFromFile("blah.jpg"))
then I get a runtime error and it opens fopen.c and apparently it stopped at  
Code: [Select]
if(*file==_T('\0'))
        {
            errno=EINVAL;
            return NULL;
        }


  I know that changing the _ITERATOR_DEBUG_LEVEL=0 can affect libraries that set it to something else so I have two questions:

1.Does setting "_ITERATOR_DEBUG_LEVEL=0" in the preprocessor definitions affect SFML?

2.If so, how do I get the boost multi array library to work when adding _ITERATOR_DEBUG_LEVEL=0 breaks SFML and vice versa?

Also, apparently changing to release mode can fix boost multi array but I get a fatal error and it takes me to base.hpp and on line 136 it says
Code: [Select]
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);

Also note that I realize this is a problem with boost multi array and not SFML.  Thanks.

EDIT: I can also post the source code if needed but it's not organized wonderfully right now :)

7
General / Trouble with sf::vector2
« on: November 11, 2011, 10:38:27 am »
Quote from: "P@u1"
what is your problem?


Code: [Select]

typedef sf::Vector2<double> Vector2d;

Vector2d vec(1, 5);
//and you are done.
//if you want to change the coords just do
vec.x = 42;
vec.y = 1337;


I'm getting an error from setting vec:"this declaration has no storage class or type specifier." For some reason vec has no members :/

EDIT:I put it in my main function and it seems to work.

8
General / Trouble with sf::vector2
« on: November 11, 2011, 07:36:33 am »
Hello, I've been having trouble creating a variable for a vector.  Here's some pseudocode of what I would like to do:

vector2 vec(0,0)
vec.x = 1
vec.y = 5

I'm using SFML2 so I'm not sure if 2d vectors are used the same.  If someone could post a sample of how to do this, that would be great.

9
General / Weird drawing issue
« on: November 10, 2011, 03:21:23 am »
Okay, I moved the App.display() part out of the loop so it only has to execute once.  I swore I've tried this before but it seems to work now.  I'll keep you guys posted :P

EDIT:Also noticed my arrays are weird...I'll fix that.

EDIT2:Alright I had a few more problems that I fixed.  Everything's perfect now!  Programming is addicting in a weird way...anyways here's the fixed code.  If you have any more suggestions for improvement, fire away!

Code: [Select]
void drawTiles(sf::RenderWindow &app)
 {
for(int x = 0; x < tileMapWidth-1; x++)
{
for (int y = 0; y < tileMapHeight-1; y++)
{
int textureIndex = tileMap[y][x];
sf::Texture texture = tileTextures[textureIndex];
sf::Sprite sprite;
sprite.Scale(.1875, .1875);
sprite.SetTexture(texture);
sprite.SetPosition(x*tileWidth,y*tileHeight);

app.Draw(sprite);
}
}
app.Display();
 }

10
General / Weird drawing issue
« on: November 10, 2011, 03:07:21 am »
Quote from: "Tex Killer"
I guess you're you using separate images for each tile... Am I right?
You can use one big image with all tiles on it, but if you are following a tutorial that will give you some trouble.

Why are you scaling the sprites before drawing?


Yeah, I'm using separate images at the moment.  I'm using the tutorial as more of a guideline; I think I could easily just use one image and divide it up for the sprites I need.  I'm not sure if this will fix my problem though.

As for the scaling, I'm not sure heh.  I've been trying all different orders in which the drawing lines are organized and nothing seems to work.  I'm quite sure the problem lies in this code too but perhaps not.

EDIT:Also, if I take the
Code: [Select]
sf::texture Texture = tileTextures[0];

part out of the function then it executes over twice as fast, however I need to keep it inside the function as when I draw the texture I first get it from the array so I know which tile to draw.  Perhaps having one image could speed this up somehow.

11
General / Weird drawing issue
« on: November 10, 2011, 12:10:29 am »
Hello.  I've been creating a tile engine based off of Nick Gravelyn's "old" tile engine tutorials(which are made with C#/XNA).  I'm doing mine in C++/SFML but I seem to be having some issues drawing the tiles.  The code below is the function that I'm currently using to draw the tiles.  I'm encountering a few problems:
1.  First of all, it takes at least four seconds to draw these 70 tiles
2.When it's done drawing, I end up with a checkerboard of empty spaces and tiles(alternating)
3.While drawing, all the tiles blink, even where there should be a tile in a blank spot.

Hopefully these can all be fixed in one fell swoop :)

Code: [Select]
void drawTiles(sf::RenderWindow &app)
 {

for(int x = 0; x < tileMapWidth; x++)
{
for (int y = 0; y < tileMapHeight; y++)
{
int* textureIndex = tileMap[y, x];
sf::Texture texture = tileTextures[0]; //[*textureIndex+1];

sf::Sprite sprite;
sprite.Scale(.1875, .1875); // 48/256 (tileWidth/size of original image)
sprite.SetTexture(texture);
sprite.SetPosition(x*tileWidth,y*tileHeight);
app.Draw(sprite);
app.Display();


}
}
 }


If you have any questions/comments on the code, feel free to ask.  I can post the whole thing if needed, but I'll see if anyone can tell what's wrong by just seeing this function.

12
Graphics / sf::Text error VC2005
« on: June 03, 2011, 06:33:06 am »
I'm having the same problem in VC++ 2010!

13
Graphics / Local/global position problem
« on: June 03, 2011, 04:08:30 am »
Well, I did finish my pong game now.  It just needs a bit of tweaking to avoid some collision glitches.  This thread is solved I guess unless someone has an answer to my edit question from my last post.

Quote
Wait, I guess that means I should create everything with their origin at 0,0 then set their position to something else. Does it have to be done like this?

14
Graphics / Local/global position problem
« on: June 03, 2011, 12:01:17 am »
Quote from: "Lupinius"
For me the shape appears at (300, 300), which i do believe is correct because the shape itself starts at (200, 200) and is moved by (100, 100) afterwards.


But isn't that how the move function works?  SetPosition sets the position but it's setting it in local coords or something because it treats the origin of the shape(which is in the middle of the screen pretty much) as (0,0).  I want the top left of the screen to be (0,0).  Perhaps my call to the transFormToGlobal or whatever it is called was incorrect because I should have called it on each point.  I feel like I"m missing something though because I assumed SetPosition and GetPosition would give me the global coordinates.

EDIT: Wait, I guess that means I should create everything with their origin at 0,0 then set their position to something else.  Does it have to be done like this?

15
Graphics / Local/global position problem
« on: June 02, 2011, 11:40:58 pm »
Quote from: "Laurent"
A minimal code would be better.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::Shape shape;
    shape.AddPoint(200, 200, sf::Color::White, sf::Color::White);
    shape.AddPoint(200, 300, sf::Color::White, sf::Color::White);
    shape.AddPoint(300, 300, sf::Color::White, sf::Color::White);
    shape.AddPoint(300, 200, sf::Color::White, sf::Color::White);

    shape.SetPosition(100, 100);
    sf::Vector2f position = shape.GetPosition();
    std::cout << position.x << " " << position.y << std::endl;

    return 0;
}

This code should display "100 100". And I'm sure it does ;)


Yes it does display "100 100" but when I draw it to the screen, it's over half way down.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Position Test");

    sf::Shape shape;
    shape.AddPoint(200, 200, sf::Color::White, sf::Color::White);
    shape.AddPoint(200, 300, sf::Color::White, sf::Color::White);
    shape.AddPoint(300, 300, sf::Color::White, sf::Color::White);
    shape.AddPoint(300, 200, sf::Color::White, sf::Color::White);

    shape.SetPosition(100, 100);

    sf::Vector2f position = shape.GetPosition();
    std::cout << position.x << " " << position.y << std::endl;

while (App.IsOpened())
{
sf::Event Event;

while(App.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}
App.Clear();
App.Draw(shape);
App.Display();
}

    return 0;
}


EDIT: ie it's not giving me global coordinates.  If I change setposition to (0,0) then it will be drawn at where I first set the points but it will still cout 0 0.

Pages: [1] 2