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

Pages: [1]
Graphics / Another View Question
« on: May 05, 2011, 07:50:16 am »
I'm having trouble wrapping my head around View.  Basically I want to create a world that say is 1024x768 but the screen size is only 800x600 (as example values).  I want the view to shift based on if an arrow key is pressed.  Kind of like Asteroids or Geometry Wars where the View centers on the player and the world moves around them.

Edit: Forgot to mention what I have so far.  I basically have some code that has a Sprite with a position at the center of the screen and whenever I push an arrow key I try to move the view 30 units.  The Sprite just stays and doesn't move.

Feature requests / SFML on Android using NDK?
« on: April 21, 2010, 04:47:22 am »
I'm planning on getting a new phone soon and will probably get an Android phone.  I was wondering, would it be possible to port SFML to Android using the Android NDK?  What would be needed for this venture?

Graphics / SFML 2.0 Drawing doesn't work
« on: June 14, 2009, 05:58:47 am »
I tried to do a simple test using SFML 2.0,
Code: [Select]

sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "O hai");
sf::Shape Rect=sf::Shape::Rectangle(50,50,200,100,sf::Color::White);
// Start game loop
    while (Window.IsOpened())
        // Process events
        sf::Event Event;
        while (Window.GetEvent(Event))
            // Close window : exit
            if (Event.Type == sf::Event::Closed)

        // Clear the screen (fill it with black color)

        // Display window contents on screen

and I got an access violation exception (something to do with OpenGL state or something).  I tried the code with the SVN trunk version and everything worked fine.  

Basically my question is, How usable is SFML 2.0 / when should we be able to essentially "beta test" it?

General / SFML and Box2D
« on: April 03, 2009, 12:46:33 am »
I'm trying to set up Box2D with SFML.  I am kind of confused when it comes to setting up Box2D.  I was wondering if someone had example code that I could use or if someone could help me out with a few questions concerning both libs put together.  

Basically I have SFML::Drawables in my game.  How do I give them Shapes, etc in Box2D so that I can perform collisions with Box2D?  How do I set up the Box2D world (my window is 1024x768...so how big should my World be then)?  If I move an object in Box2D do I have to copy the movement back into the SFML Drawable?  

I am planning on using Box2D mainly for collision.

General / #include problem (more C++ related than just SFML)
« on: March 11, 2009, 03:28:46 am »
In my program I'm trying to set up some kind of hierarchy.  A ResourceManager holds the game's resources (which includes Levels), Levels have an Update function which can add enemies to the game if certain criteria are met, and Enemies use the ResourceManager to set its image to its Sprite.  So if I do a #include for each required file, I end up getting an infinite recursive include loop (Visual Studio then throws "too many include files").  Now, if I use a #pragma once (which I had no idea what it was until this day...still don't rly know what it is) I get weird compiler errors (parts of my code that used to work before now dont and now cmath and list are breaking too).  How do I fix this?

EDIT: ok quick "Update:" I thought I had fixed the problem and deleted this thread; however, in my Level file if I comment out #include Enemy.h I do not get any errors; however if I uncomment it I get a plethora of weird erros:

Code: [Select]

Error 14 error C2143: syntax error : missing ';' before '{' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\cmath 20 SFML Game
Error 20 error C2143: syntax error : missing ',' before '<' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list 20 SFML Game
Error 71 error C2143: syntax error : missing ';' before 'namespace' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iostream 12 SFML Game

Now I think it's because in my ResourceManager class I have a vector of Level pointers (to store the levels).  For some reason if I include Enemy in level, it breaks something.  Here are the includes in Enemy, Level, and ResourceManager, if that helps:
Code: [Select]

#pragma once
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <vector>

#include "Enemy.h"

#ifndef LEVEL_H
#define LEVEL_H

#pragma once
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

#include "ResourceManager.h"
#include "Player.h"

#pragma once
#include <vector>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "Level.h"

Another update, I moved most of the local include files into the cpp files.  It mostly has fixed it...until I need to actually put include files into headers.

Audio / sf::Sound SetPosition, how does it work?
« on: March 05, 2009, 06:13:03 am »
I'm having trouble getting the SetPosition thing to work.  I'm thinking my problem is my z value, but I'm not exactly sure.  I define a position by doing a sound.setPosition(x,y,0), x and y being the position of the drawable at initialization.  I tried changing the 0 to a 1 or a -1 and it still didn't work (no sound was played).  what am I doing wrong? It's probably something real stupid...

General / How does SFML link to the CRT (in Visual Studio)?
« on: February 27, 2009, 04:33:40 am »
Ok, so I'm trying to limit the number of dlls my exe uses (I for some reason prefer static linking over dynamic linking).  Also I want to use the SPARK particle library thing and it won't link statically.  If I link the SPARK library dynamically, it asks for SFML to also be linked dynamically.  I then realized that maybe the problem was a /MT vs /MD thing.  However, when I compile with the /MT I get a bunch of "already defined" linker errors.  I now use /nodefaultlib and then I get over 9000 linker errors (well like 81).  They all say stuff like:
Code: [Select]

Error 1 error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" (__imp_?_Lock@_Mutex@std@@QAEXXZ) sfml-window-s.lib blank

now my question is, in Visual Studio, does SFML link against the dynamic CRT, even as a static library?  How can I fix this error?  What libraries do I need when I use /nodefault lib?  I know this is more of a visual studio question, but any help would be greatly appreciated.  

On another note, how is Code::Blocks?  If I cannot remedy this situation, I wouldn't mind using Code::Blocks, I just have a few questions:
What are Code::Blocks' dependencies?
If it's not like VC++ (as it has the "visual" part removed) does it create leaner, faster programs?
I'm sure that if I use Code::Blocks it would make my project more easily cross platform.  

Anyway I've been struggling with this static CRT vs Dynamic thing forever and just want to get to work on my game...

SFML website / SFML Audiostream tutorial links to french site
« on: February 25, 2009, 11:05:46 pm »
the (english) site for audiostreams (from the SF::Music page) links to the french site.  Just wanted to let you guys know.

Audio / Looping a music from a certain point
« on: February 11, 2009, 01:15:15 am »
A lot of songs have some kind of intro sequence in the beginning but then start to loop from another point of the song.  Is there a way to do this in SFML? If not, would the best alternative way be to just manually split the song, play the intro piece, then time it, play the other part then loop?  The only problem with the latter is I seem to have some kind of lag when I play musics, (it's not a loading issue, I load at a different part of the program much before execution begins.

General / Single instance of a class
« on: February 08, 2009, 05:33:36 am »
Ok, this is more of a general C++ question.  I'm trying to use a ResourceManager class to manage resources.  However I want to keep only one instance per program (as it stores all the resources for all of the program) or atleast I want its data to not change per instance if I make multiple instances.  

So basically, is there a way I can make a static reference to one instance and just pass that around?  

I'm just wondering how I would use a class to manage resources.  I did this in Java programming by just making the constructor private and having one static reference, but I understand C++ is different (and that I could just use namespaces).  

Anyway, I figured since the tutorial referenced a Manager class that people would have used it here.

Audio / How to use an Object Manager with sf::Music? (NonCopyable)
« on: February 06, 2009, 05:43:35 am »
Ok, so I'm trying to make a simple Resource Manager that holds all my resources (Images, Music, Fonts, etc).  

The problem I am getting is when I ask for a music, I get an error with the NonCopyable thing (which threw me off at first until I realized that it was the Music, not really a Thread that I had created).  

here is my code for the resource manager (Kind of cannibalized from tutorials and other posts on this forum):

Code: [Select]

//function for loading the music
void ResourceManager::loadMusic(const std::string& name, const std::string& filepath)
    // Only load image if key does not already exist (no duplicate images)
    if(Music.find(name) == Music.end())
        Music[name] = new sf::Music();
Music[name]->OpenFromFile(filepath);//load image from the file
//function for returning the music requested
const sf::Music& ResourceManager::getMusic(const std::string& name)
    return *Music[name];
//call from main that asks for the music, Resources being a ResourceManager
const sf::Music MenuMusic=Resources.getMusic("FlatOut.ogg");

I'm kind of new to C++ (have had only about a semester-ish of it) but have extensive experience with Java.  

Should I have the getMusic() function return a pointer instead?  I'm a little bit weary with pointers (I still can't get into the habit of using the -> operator...i know i'm weird).

Graphics / Fullscreen mode? (non-windowed way)
« on: January 30, 2009, 03:42:58 am »
Probably a noob question: is there a way to set fullscreen but keeping an aspect ratio? (Like setting the monitor's resolution to 1024*768 and then fullscreening the window w/o the title bar scrolling across?)

Graphics / Rounded Rectangles
« on: January 28, 2009, 08:29:47 pm »
I was wondering, does SFML have a way to do RoundedRectangles (with or without OpenGL)?  If not, would it be more efficient to use primitive shapes to kind of make a rounded rectangle or to use an image?

Just wondering, thanks!

Graphics / SFML and Particle Systems
« on: January 19, 2009, 09:12:22 pm »
Hey all, sorry if this question has been asked before,
I'm new to SFML and was wondering if it supported particle systems and all.  Also are there any prebuilt collision libraries? Collision isn't that big of a deal (I have dealt with pixel perfect collision before, but I was wondering if there were any better built in collision or third party libs).  

I'm moving to SFML from SDL+OpenGl and have previously programmed in Java.  I'm planning on making a 2d sprite based spaceshooter thing with particle effects for explosions, lasers and such.  

Thanks, and sorry if I'm an obnoxious nub ;)

Pages: [1]