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

Pages: [1] 2 3
1
General discussions / Problems with gcc 4.6
« on: April 09, 2011, 10:16:29 am »
Ok. I think I'll do that. Thanks for your quick answer.

2
General discussions / Problems with gcc 4.6
« on: April 09, 2011, 09:40:28 am »
Since I have upgraded to gcc 4.6, I get errors when compiling my sfml project. For example:  

Code: [Select]
/usr/include/SFML/System/ResourcePtr.inl:31: error: ‘NULL’ was not declared in this scope

I looked this up and it seems that in gcc 4.6 STL headers don't include <cstddef> any longer.

I could manually work around this by adding "#include <cstddef>" to ResourcePtr.inl myself but I hope there is a better way than that.

Is anyone else using gcc 4.6 getting this problem?

3
General / A few Questions..
« on: October 31, 2010, 11:04:21 pm »
Hehe nice. I prefer paper actually since my ideas stay there forever. Also I don't have to rub it clear every so often ;)

If a function isn't in scope then declare it at the top. For example:

Code: [Select]
void myFunction(); // This is the declaration

int main() {
    ...
    myFunction(); // We can call our function here now
    ...
}

void myFunction() {
     // Code for myFunction goes here
     ...
}



Quote
Also where does player + enemy score go. I've finally got a scoring system that i'm pleased with but i don't know where to put it. Would I be correct in thinking that it would be best in the while loop.

I'm not sure what you mean by this. I'd make some variables for player and enemy score. Then if player scores then increment his score.

Btw I won't be able to reply as much now because my exams are starting. In fact my first one starts in 3 hours ;)

4
General / A few Questions..
« on: October 31, 2010, 09:34:41 pm »
@Disch

Lol. Haha. Yeah it's only for pong. But thanks for the explanation though. I might find it handy in the future.

@Father_Sloth

Hope everything is going well. Just some tips:

- If you get stuck on some logic or something, try using pen and paper. Don't worry if you can't think of a solution immediately. Problem solving takes time.

- If you get stuck between a few choices on how to do something (like how to detect scores), just try one way and see if it works. Making mistakes and trial and error are good ways to learn.

- Build up incrementally. Don't worry about spacebar and scores yet. First try to get a ball moving on the screen. Then add paddles that can move. Then add collisions, etc. This will make things easier and much less daunting.

5
SFML projects / Ultimate Zombie Fighters
« on: October 31, 2010, 09:23:00 pm »
That's a nice website.

Thanks for the link Nexus.

6
General / A few Questions..
« on: October 31, 2010, 12:34:41 pm »
You could do it that way. Or you could check the ball's x position. If the x position is less than a certain value, say 0, then player 2 should get a point. If the x position is higher than a value, say 640(or whatever your game width is), then player 1 should get a point.

7
General / A few Questions..
« on: October 31, 2010, 11:29:57 am »
Quote
Side note: Should I
1) Make the walls in like paint and just load them as a sprite.
2) Construct them using a simple shape made by SFML.
3) Do Number 1 but load them as an Image?


Do number 1. You will use sprites in most typical games so it's best to get use to them.

8
SFML projects / Ultimate Zombie Fighters
« on: October 31, 2010, 02:55:59 am »
I'm a bit shaky with my design pattern knowledge as well. But here is basically what I know:

A factory basically creates and returns objects.

Say I have a class called Enemy. And say that I have some other classes called Zombie, Robot and Ninja that are inherit Enemy. I can then make a EnemyFactory class that let's me easily create any type of enemy along with it's color and HP. For example:

Code: [Select]
Enemy *someEnemy = EnemyFactory::create("Robot", "red", 100);

This will create a red Robot with 100 health.

I needed something like this in UZF so that I could create objects from strings scanned from xml files.

----------

I couldn't find any good links about learning about factories myself. Probably best to google it and read what's there.

9
General / A few Questions..
« on: October 31, 2010, 01:10:56 am »
Actually it is very simple. If the ball hits a horizontal wall (like the ground) you just reverse it's y-velocity. And if the ball hits a vertical wall you reverse it's x-velocity.

Unless you have walls that are angled in different directions, you don't need to do calculations using collision angles and stuff.

10
General / A few Questions..
« on: October 30, 2010, 12:31:40 am »
Code: [Select]
float Left = 0.f;

The ".f" explicitly marks a value as a float instead of a double. For more info see here: http://stackoverflow.com/questions/2391818/f-after-number-float-in-objective-c-c

11
General / A few Questions..
« on: October 29, 2010, 07:27:41 pm »
You'll need to add it to your header search path.

Quote
p.s. also just a little question about sfml. I am reading the tutorials and I keep on seeing this " .f " - what does it mean?


I didn't notice anything like that last time I checked. Can you give an example?

12
General / Help! Can't static link to SFML.
« on: October 29, 2010, 03:00:39 pm »
Try using gcc 4.5. This solved some of my problems when compiling on windows.

13
General / A few Questions..
« on: October 29, 2010, 02:56:37 pm »
You have included the right headers but the compiler can't find them. So you'll need to add SFML's include/ directory to your search path. I haven't used xpath before but this page gives some information on how to add directories to your search path: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/XcodeProjectManagement/210-Building_Products/building.html#//apple_ref/doc/uid/TP40002693-SW23

14
General / A few Questions..
« on: October 29, 2010, 05:57:32 am »
Hey Father_Sloth

It seems like you are new to game programming. My suggestion is to first make a very simple game.

Whenever I learn a new framework or library I try to make a pong game. Pong games are good because they are simple to code and teach you how to deal with sprites, collisions, controls, sounds, etc. After you finish that you'll get a good understanding of the basics and can move on to your next project.

I learnt SFML from the offical tutorials. In fact I think the tutorials are one of big strengths of SFML because they are so simple yet so comprehensive.

As for your errors, it seems that you have not specified the SFML include/ directory in your include path.

15
General / A few Questions..
« on: October 25, 2010, 02:06:29 am »
Quote
1) How can I get the player sprite to face the mouse?

You need to first get the difference in position for the mouse and player. Then you arctan (tan inverse) the x/y of the position difference. Finally use sf::Sprite::SetRotation() to set the angle. Here is the code I use in uzf:

Code: [Select]
void Player::onUpdate() {
    Input *input = Input::getInstance();

    sf::Vector2f mouseToPlayer = input->getMousePosition() - getPosition();

    float facingAngle = atan(mouseToPlayer.x/mouseToPlayer.y);

    if(mouseToPlayer.x == 0 && mouseToPlayer.y == 0)
        facingAngle = 0;

    facingAngle *= 180/3.14159; // Convert to degrees

    // atan() returns an angle between 0-180 therefore it needs an offset of 180
    // when it is in the negative-Y quadrants
    if(mouseToPlayer.y >= 0) {
        facingAngle += 180;
    }

    setAngle(facingAngle);
    ...



Quote
2) how can I get the Zombies to go towards the player?


This is more trickier.

If you don't have any walls and obstacles, then you can make the zombies head straight for the player. Again using some simple maths you can figure out what the x and y speed of the zombie needs to be.

If you have walls however then you will need to do some pathfinding. Try looking up A* (a star) path finding. I used the micropather library instead of writing my own A* code. It does most of the work for you but it isn't fully straightforward.

This was probably the trickiest part of the game for me to code. There were issues like unit and wall sizes not having the same grid size that took me a while to find a workaround for.

Quote
3) How should I do the maps? Are their any editors that would work best for my needs (medium sized maps with collision and as the player moves, it scrolls.)


For this you have 2 choices: Tile-based map editors, and vector based map editors.

Tile-based map editors are the easiest to use but also the most inflexible as everything is based on the grid size. Most of them export to easy to parse files and so the code to load maps is simpler.

For UZF I used Inkscape, a vector based editor. Inkscape is actually a generic vector editing program but you can still use it to make game maps. It is the most flexible option as it has things like polygons, layers and more advanced functionality. You can also use the description fields of shapes to add game related object information. However the .svg file format is in xml and is quite complicated. So I only implemented a very basic implementation that only handles rectangles with no rotation.

Both types of map editors support medium sized maps and collision. Scrolling is something that you have to code yourself. Thankfully SFML's View classes make scrolling quite simple.


Some parts of the game can be tricky but the more you code the better you get :). Good luck with your project.

Pages: [1] 2 3
anything