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

Pages: [1] 2
1
System / SFML 2 Randomizer
« on: June 11, 2012, 06:08:17 pm »
Hello,
I've used SFML 1.6 for a little while, and when I made the switch to SFML 2, I noticed sf::Randomizer is gone.  Why was it removed?  And is there a new method built into SFML 2 that I could use to get random numbers?

Thanks.

2
Graphics / Trouble with sf::Text
« on: June 01, 2012, 06:39:07 pm »
Hello,
I'm having trouble with the sf::Text class.  Here is part of my code:

// gui.cpp

playerCardGUI::playerCardGUI()
{
    texture.loadFromFile("data\\GUI\\playercard.png");
    texture.setSmooth(false);
    sprite.setTexture(texture);
}

playerCardGUI::~playerCardGUI()
{
}

void playerCardGUI::create(unsigned short int argOwner, NATIONALITY natl, sf::Vector2f pos)
{
    texture.loadFromFile("data\\GUI\\playercard.png");
    texture.setSmooth(false);
    sprite.setTexture(texture);

    playerName.setFont(data.mainFont);
    health.setFont(data.mainFont);
    ammoMag.setFont(data.mainFont);
    ammoTotal.setFont(data.mainFont);

    playerName.setString("Name");

    owner = argOwner;

    if(natl == US)
        txNational.loadFromFile("data\\GUI\\ally_US.png");
    else if(natl == GR)
        txNational.loadFromFile("data\\GUI\\axis_GR.png");

    sprite.setPosition(pos);
    playerName.setPosition(pos);
}

void playerCardGUI::update(int HP, int ammo, int totalAmmo)
{
    std::stringstream stream;

    stream << HP;
    health.setString(stream.str());

    stream.clear();
    stream << ammo;
    ammoMag.setString(stream.str());

    stream.clear();
    stream << totalAmmo;
    ammoTotal.setString(stream.str());
}

void playerCardGUI::draw()
{
}
// gui.h
#ifndef GUI_H
#define GUI_H

class playerCardGUI
{
    private:
        // graphics variables
        sf::Sprite sprite;
        sf::Texture texture;
        sf::Sprite spClass, spNational;
        sf::Texture txClass, txNational;

        // text variables
        sf::Text playerName;
        sf::Text health;
        sf::Text ammoMag, ammoTotal;

        // misc variables
        unsigned short int owner;
    public:
        playerCardGUI();
        ~playerCardGUI();
        void create(unsigned short int argOwner, NATIONALITY natl, sf::Vector2f pos);

        void update(int HP, int ammo, int totalAmmo);
        void draw();

    friend class Player;
};

#endif // GUI_H

Specifically, the issue is with playerName.  When I try to compile this, it works fine-- until I close the main program window.  Then the process continues to run until I manually end it using the Windows Task Manager.

I don't see anything wrong with my code.  Does anyone else see anything wrong?
Thanks in advance.

3
Graphics / Is there a way to rotate sf::Rects?
« on: May 15, 2012, 01:11:22 am »
Hello,
I'm developing a World War II shooter.  Look at this screenshot:

The red line represents where the bullet of the rifle will go.  Due to low FPS when trying an actual bullet approach, I've gone with a hitscan approach.
Here is where the problem comes in: I don't want my bullet to go through solid blocks.  The first step in coding this is to find where the bullet will actually go.  My typical method of collision detection (create rects of the 2 objects that might collide, compare their edges) won't work, since I'm dealing with a line (actually a thin, rotated sf::RectangeShape, but anyways), not a box.  What I need is a way to rotate a sf::Rect so it would fit the profile of the line.
Is there a way to do this?  Other solutions are also appreciated.  :)

4
Hello,
Is there a function (in SFML 2) that will allow me to maximize/resize my window without changing how big the sprites look onscreen?

Thanks in advance. 

5
General / Can't understand CMake tutorial for SFML 2
« on: April 12, 2012, 05:36:14 pm »
Excuse me if I'm incompetent.
I'm fairly new to C++, and after using SFML 1.6 for a while, I've decided to try out SFML 2 (my algorithms weren't very efficient which lead to poor performance, and I'm hoping SFML 2 will run a bit better).  Thing is, I don't understand the CMake tutorial.  At all.

If you need my computer information, I wish to use SFML 2 with the MinGW compiler on Code::Blocks, and my computer OS is Windows 7.

To start off:
How exactly do I run CMake-gui?  I can't find an .exe file anywhere.

6
Graphics / Blurry sprites?
« on: April 06, 2012, 05:02:10 pm »
Hello,
Using SFML I've noticed my sprites end up blurry.  For example, this is my source .png file:
http://us.fotolog.com/chuckleluck/124000000000004931/
This is the sprite, assembled in my SFML program:
http://us.fotolog.com/chuckleluck/124000000000004932/?share=1
As you can see, the edges are blurry.  Is there a way to disable this feature?  I want my program to be pixel-perfect.

7
Hello,
Every time I create a new project, I have to place the .dll's I need (sfml-graphics.dll, sfml-system.dll, etc.) in the location of my project file.  This works, but it's becoming a nuisance having to copy & paste those files every time I create a new project.  Is there a way I can make it so SFML can find the .dll's in a central location (say, my C: drive)?

Thank you in advance.

8
SFML projects / Fireteam
« on: March 10, 2012, 11:07:06 pm »
This is my first game I've made in SFML.  It is called Fireteam.  It's a sidescrolling WW2 shooter, coded, developed and drawn by myself.



Features:
- Updated on a regular basis
- 2 game modes (Capture the Flag and Team Deathmatch)
- A menu!
- 4 player splitscreen!
(I know it's not much, but I hope to expand it a lot)

Basically, you play as one of four soldiers in a game.  You're either on the Axis or the Allies (at the moment, the only Axis member is Nazi Germany, and the only Allies member is the United States).  There will be more maps, but at the moment the only map is the Battle of the Bulge.
There are 4 classes to select from (at the moment the only difference is the "equipment" the player has access to, either a first-aid kit or a radio): Rifleman, Support, Sniper and Raider.

Fireteam uses SFML for just about everything, from graphics to sound to random number generation.

You can download the latest version (INDEV 1.1) here:
http://db.tt/ITTFnYj1
All controls and general information are explained in the readme file.

NOTE: If you play with 4 players, you'll either need a keyboard that can support a lot of keys being pressed at once, or have multiple keyboards (for example, I use my laptop's built-in keyboard and a USB wireless keyboard).

9
Network / How do I use the network-sockets source code?
« on: March 07, 2012, 07:20:51 pm »
Hello,
I decided to try out the source code provided in the "Network - Using Sockets" tutorial on the website.
How exactly do I use it?  I have 2 specific questions:
- What IP should I enter on the client?  I'm running the client and server on separate computers, but on the same local network.
- Do I have to do any preliminary actions before running the client and server, such as port forwarding?

Thanks in advance.

10
Graphics / Is there a way to not have to include image files?
« on: March 05, 2012, 05:45:41 pm »
Hello,
Is there a way to load images so they don't have to loaded each time the .exe file is run?  Like if I had this bit of code:
"image.LoadFromFile("imgFolder\\img.png");"
What if the .exe file got moved to my desktop, where there isn't a folder named imgFolder?  Or if I distributed my program, and I didn't want to include the source images?  Is there a method in SFML to "remember" what the images were?

11
General / Multiple Events Running At the Same Time?
« on: December 15, 2011, 06:17:15 pm »
Hello,
I'm wondering if SFML supports multiple events running at the same time, and if so, how I can implement it.
Say, for example, you had a game with a man driving a car.  To accelerate, you press Spacebar.  To turn, you use the left and right arrow keys.  What if someone wanted to accelerate and turn at the same time?
From what I've seen, it appears SFML can only handle one event at a time.

12
Graphics / How to use Intersects()?
« on: December 14, 2011, 07:20:05 pm »
Hello, I'm fairly new to programming, and the documentation for the `Intersects()' method, part of sf::Rect, confuses me.

This is the code I wrote:
Code: [Select]
if(Intersects(rcBoxA, rcBoxB))
     return true;

(Both boxes are of type sf::Rect<int>)
This is the error I received:
"Error: `Intersects' undeclared (first use this function"

How do I correctly use `Intersects()'?

13
Graphics / Need to flip "rotate" axis
« on: November 28, 2011, 06:43:13 pm »
Hello,
I want to make a simple program that allows the user to drive a car.  Pressing "W" would make the car go forward, and pressing A and D would make the car turn left and right, respectively.
Now, to make the car sprite turn realistically, I'm using the Rotate function.  This works fine for turning left (counterclockwise), as the axis on which the sprite turns is at 0, 0, and thus the top left corner.  However, for turning right, the car goes in reverse (clockwise).  I need a way to change the axis on which the car rotates, from 0, 0 to 46, 0 (which happens to be the rightmost pixel coordinate on my sprite image).
Is there a function I can use to change the axis on which Sprite.Rotate() rotates on?

14
Window / [SOLVED]Need sf::Clock to be more specific
« on: November 23, 2011, 04:56:12 am »
Hello,
I'm working on a program and I need my character's feet to move back and forth while he's walking.  I've got everything working with sf::Clock. Here's a snippet of my code:
Code: [Select]
void MovePlayer(int x, int y, int Player)
{
    switch(Player)
    {
        case 1:
            g_sPlayerHead.Move(x, y);
            g_sPlayerBody.Move(x, y);
            g_sPlayerFeet.Move(x, y);
            g_sPlayerArms.Move(x, y);
            int timer = FootImgClock.GetElapsedTime();
            switch(timer)
            {
                case 0:
                    g_sPlayerFeet.SetSubRect(g_rcFeetMveA);
                    break;
                case 1:
                    g_sPlayerFeet.SetSubRect(g_rcFeetMveB);
                    break;
                case 2:
                    FootImgClock.Reset();
                    break;
            }
        default:
            break;
    }
}


The feet move too slow for my liking, once every second or so.  How do I fix this?  Is there a version of sf::Clock that measures in miliseconds?

15
Graphics / Can you draw a part of a sprite instead of the whole thing?
« on: November 17, 2011, 04:43:50 am »
Hello,
I want to incorporate frame-based animation in my game, but I don't want to have to draw and load each individual frame as a different image and sprite.  My solution is to draw all the frames on one image, load it, then draw in the window only a single part of that image, the part I want it to display.
Is there a built-in function that I could use to:
A. Draw only part of a Sprite, or
B. Apply image effects on only one section of an image, so I could apply 100% transparency on the parts I don't want to display?

Pages: [1] 2