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

Pages: [1] 2
1
General / FPS cut in half on Windows 7
« on: August 14, 2009, 11:49:34 pm »
Is this normal? (compared to Windows XP)

I haven't noticed anything else slow down since I switched OS.

I have an old laptop but as I wrote, nothing else is slower than on Win XP.

Has anyone else noticed any slow-downs comparing XP and 7?

2
General / Trigonometry, float or double?
« on: July 06, 2009, 04:22:50 pm »
Which type is the most commonly used when dealing with trigonometry? If I define PI as a float and use the float versions of sin, cos etc. will I get enough precision? I'm using floats atm and it seems enough.

I know the SFML methods take float parameters but my math teachers always said I should use as many decimals as possible while calculating and then round off in the end.

The thing I'm working on is not gonna be sent up in space, I'm just curious :P

3
Graphics / Retrieving correct coordinates
« on: July 03, 2009, 03:23:35 pm »
Hello, let's start off by showing a screenshot.



Above you see my beautiful car with only 3 wheels :). I know I read an article a while back about how to make proper steering for a car. Iirc the car should be rotated around the point circled on the picture above (the intersection point of the left wheels' lines) and not around the center of the car.

In order to do this I need to know two points on each line (for the intersection test I'm using), but I don't know how to retrieve them. First I tried to get the points from the sf::shape::line but I can't use those values directly, I guess because of the way I have structured my code. This is how i do it (this code is only temporary, it looks like s*it I know :)):

Code: [Select]
struct Sub: public sf::Drawable
{
Sub(float _dir = 0): dir(_dir) {}

void Render(sf::RenderTarget& Target) const
{
Target.Draw(subSprite);
Target.Draw(centerDot);
Target.Draw(directionLine);
}

float dir;
sf::Shape centerDot;
sf::Shape directionLine;
sf::Sprite subSprite;
};

struct Base: public sf::Drawable
{
Base(float _dir = 0): dir(_dir) {}

void Render(sf::RenderTarget& Target) const
{
Target.Draw(baseSprite);
Target.Draw(centerDot);
Target.Draw(back);
Target.Draw(frontLeft);
Target.Draw(frontRight);
}

float dir;
Sub back;
Sub frontLeft;
Sub frontRight;
sf::Shape centerDot;
sf::Sprite baseSprite;
;
};


In this case the wheels are of type Sub and the body of type Base. This is how I create the objects (some redundant code here as well):

Code: [Select]
Base base;
base.baseSprite.SetImage(baseImage);
base.SetPosition(400, 300);
base.SetCenter(base.baseSprite.GetSubRect().GetWidth() / 2, base.baseSprite.GetSubRect().GetHeight() / 2);
base.centerDot = sf::Shape::Circle(base.GetCenter().x, base.GetCenter().y, 2, sf::Color::White);

Sub sub;
sub.subSprite.SetImage(subImage);
sub.SetPosition(96, 0);
sub.SetCenter(sub.subSprite.GetSubRect().GetWidth() / 2, sub.subSprite.GetSubRect().GetHeight() / 2);
sub.centerDot = sf::Shape::Circle(sub.GetCenter().x, sub.GetCenter().y, 2, sf::Color::White);
sub.directionLine = sf::Shape::Line(sub.GetCenter().x, sub.GetCenter().y - 200, sub.GetCenter().x, sub.GetCenter().y + 200, 1, sf::Color::Black);

base.frontLeft = sub;

sub.subSprite.SetImage(subImage);
sub.SetPosition(96, 64);
sub.SetCenter(sub.subSprite.GetSubRect().GetWidth() / 2, sub.subSprite.GetSubRect().GetHeight() / 2);
sub.centerDot = sf::Shape::Circle(sub.GetCenter().x, sub.GetCenter().y, 2, sf::Color::White);
sub.directionLine = sf::Shape::Line(sub.GetCenter().x, sub.GetCenter().y - 200, sub.GetCenter().x, sub.GetCenter().y + 200, 1, sf::Color::Black);

base.frontRight = sub;

sub.subSprite.SetImage(subImage);
sub.SetPosition(32, 0);
sub.SetCenter(sub.subSprite.GetSubRect().GetWidth() / 2, sub.subSprite.GetSubRect().GetHeight() / 2);
sub.centerDot = sf::Shape::Circle(sub.GetCenter().x, sub.GetCenter().y, 2, sf::Color::White);
sub.directionLine = sf::Shape::Line(sub.GetCenter().x, sub.GetCenter().y - 200, sub.GetCenter().x, sub.GetCenter().y + 200, 1, sf::Color::Black);

base.back = sub;


I think the problem is that when I retrieve the points for for example
Code: [Select]
base.frontLeft.directionLine
their coordinates are relative to frontLeft (???) and not to the 0,0 coordinate of the window as I would want.

Any help is appreciated. Other ways of doing it are welcome as well (finding two points on each drawn line, if that was unclear :))

EDIT: when I retrieve a point position of a line using
Code: [Select]
directionLine.GetPointPosition(0)
are the point coordinates stored always the inital values? or do they change as the shape is rotated etc.?

EDIT2: the screenshot above is slightly wrong (found the article), the line of the right front wheel should intersect in the same point as the left. But it doesn't change the problem.

4
SFML projects / Slotpot++ (Beta 1.1 Mar 28 2009)
« on: February 22, 2009, 02:07:39 pm »
It's finally time to release a beta version of Slotpot++. A new, polished version of my old Slotpot game, this time written in C++ (my first C++ game btw).

Game description quote from my website:

Quote
As the title implies, this game is about playing a slot machine. You need 3, 4 or 5 in a row to win. If you get the jackpot you will be able to participate in a bonus game. There are 4 different bonus games that with a little luck will give you a lot more money than a usual win.

If you are good/lucky enough you can show the world your score by submiting it to the online high score board.


For more info, screenshots and a download link, click the following link: http://www.dabostudios.net/v7/slotpotpp.php

Want to extend the game? read this:

If you want to create a new theme, follow these steps:
    1. Create a new folder with the theme name and put it here "/data/gfx/themes/'Your theme name'"

    2. Create 5 different images and name them 0,1,2,3 and 4 with 4 being the jackpot symbol (they must be .png and 96x96 pixels)


The game comes in both English and Swedish, if you want to translate it to another language what would be great. This is how you can do it:
    1. Go to "/data/languages"

    2. Make a copy of English.xml or Svenska.xml and rename it to for example Deutsch.xml for German and start translating (try to keep the sentences short if possible, otherwise it will look like shit :P ) :)


I would be happy to upload your themes and translations to my website, just send it to (dabo at dabostudios.net). A native English person is welcome to improve my English translation as well :)

As this is only a beta version, don't be surprised if there are still bugs present. Please report any bugs so I can fix them.

News:
March 28th 2009

Beta version 1.1 is now available (same link).

5
Graphics / Display only a part of a string
« on: December 20, 2008, 03:00:02 pm »
Hi, is it possible to for example display only the first 200 pixels of a string of length say 250 pixels (or any length > 200 :))?

6
Window / A time question
« on: September 15, 2008, 10:20:36 pm »
Hi, using the GetFrameTime() method correctly the hero in my game should move and jump the same no matter the FPS right? Right now he jumps higher in release mode than in debug mode. I'm suppose to use GetFrameTime() for every new calculation of the x- and y-positions of my hero right?

Haven't used time before as you can see :)

7
Graphics / Appending text
« on: August 10, 2008, 01:00:21 pm »
Hello, when updating to the newest svn my code won't compile anymore. Appending text could be done like this earlier:

Code: [Select]
sf::String sMessage("Hello");
std::string sNew("...");
sMessage.SetText(sMessage.GetText() + sNew);


But thanks to the new Unicode stuff ( :evil:  :lol: ) it doesn't work anymore. I found an "operator std::string" but I don't know how to use it (or if that's the solution).

The unicode tutorial at the website is blank.

8
Network / Online highscore
« on: August 05, 2008, 12:44:44 pm »
Hi I'm trying to add an online highscore to my game, this is my approach:
(The php-files used works)

1. Add new score to mysql database.
Code: [Select]
sf::SocketTCP sock;

sf::IPAddress server("www.dabostudios.net");

if(sock.Connect(80, server))
{
stringstream ss, ss2;
ss << iTime;
ss2 << iPoints;

// Add new score
string req = "GET /add_highscore.php?player=" +sName +"&time=" +ss.str() +"&score=" +ss2.str() +" HTTP/1.1\r\n"
"Host: www.dabostudios.net\r\n"
"\r\n";

if(sock.Send(req.c_str(), req.length()) != sf::Socket::Done)
exit(EXIT_FAILURE);

sock.Close();
}


2. Create a txt-file with the top scores from the database to later download.
Code: [Select]
if(sock.Connect(80, server))
{
// Write highscore txt-file
string req = "GET /write_highscore.php HTTP/1.1\r\n"
"Host: www.dabostudios.net\r\n"
"\r\n";

if(sock.Send(req.c_str(), req.length()) != sf::Socket::Done)
exit(EXIT_FAILURE);

sock.Close();
}


3. Download txt-file.
Code: [Select]
if(sock.Connect(80, server))
{
// Get highscore
string req = "GET /highscore.txt HTTP/1.1\r\n"
"Host: www.dabostudios.net\r\n"
"\r\n";

if(sock.Send(req.c_str(), req.length()) != sf::Socket::Done)
exit(EXIT_FAILURE);

char buffer[1024];
std::size_t received;

while(1)
{
sock.Receive(buffer, sizeof(buffer), received);

if(received > 0)
{
buffer[received] = '\0';
data.append(buffer);
}
else
break;
}

sock.Close();
}


When I check the created txt-file all scores seems to be there, but still all but the latest score are downloaded. I even cleared the mysql database and the old scores still showed up (they were not in the txt-file which is suppose to be downloaded and read from). It's like the old txt-file is cached somewhere or something like that and used instead.

Btw, does anyone see anything wrong in my code or approach?

EDIT: I've done some more brief testing, it seems to work if I sleep for 2 seconds (1 second won't work) before downloading the txt-file with all the scores. How can this be? Is my lightning fast laptop out working the web server ;)

9
Graphics / Splitting up text
« on: July 29, 2008, 09:19:47 pm »
Hi, this isen't a specific sfml question, but here it comes.

Let's say I want to display a bunch of text, but the text is not allowed to be wider than say 400px, which means I need to insert line breaks somehow. How would you solve this? I know how it could be done but I figure it would be really slow.

10
General / Something strange... (Mouse click)
« on: July 06, 2008, 01:45:08 pm »
There seems to be something strange going on when it comed to reacting to mouse clicks. I have some buttons (images, no gui) where the user can click and everything works until the 3rd click (99.9% of the time). After that you randomly have to click the button once/twice before anything happens. If I run my game with visual studios 2008 pro (start debugging) this problem never occurs but if I close visual studios and double click the executable it does. Today I discovered that the problem occures if I don't move the mouse at all during the first 3 clicks, If I move it before I click the 3rd time it works.  :?

I have tried it on 3 computers, my laptop gets the behavior described above and the other two get the problem as well, but not necessarily on the 3rd click.

I have designed my game in two completely different ways (exept for the event-loop) but the problem shows up for both. I have tried events and inputs for mouse clicks but both have the same problem. I'm linking with the static libraries.

This is the event-loop:
Code: [Select]
sf::Event eEvent;
while(renderer::getInstance()->getRenderWindow()->GetEvent(eEvent))
{
if(eEvent.Type == sf::Event::KeyPressed && eEvent.Key.Code == sf::Key::Escape)
exit(EXIT_SUCCESS);

else if(eEvent.Type == sf::Event::MouseButtonPressed && eEvent.MouseButton.Button == sf::Mouse::Left)
{
int mouseX = renderer::getInstance()->getRenderWindow()->GetInput().GetMouseX();
int mouseY = renderer::getInstance()->getRenderWindow()->GetInput().GetMouseY();
int hit = -1;

for(int i = 0; i < 5; i++)
{
if(v_iClickables[i].Contains(mouseX, mouseY)) //check clickable regions (sf::IntRect)
{
hit = i;
break;
}
}

         //if a button was pressed, act accordingly
if(hit == 0)
exit(EXIT_SUCCESS);
else if(hit == 1)
; //to be implemented
else if(hit == 2)
{
if(!bIsSpinning) //if wheels are not spinning, start spinning
{
for(int i = 0; i < signed(v_iWheelsLeftToSpin.size()); i++)
v_iWheelsLeftToSpin[i] = sf::Randomizer::Random(5, 19);

v_iWheelsLeftToSpin[0] += 10;

bIsSpinning = true;
}
}
else if(hit == 3)
; //to be implemented
else if(hit == 4)
; //to be implemented
}
}


I should be able to put together an example if you want to see the problem in action. I have no idea why the problem only occurs if you run the executable and not when you are debugging it with visual studio :?

11
Window / [Solved] Stretch to fit screen
« on: July 04, 2008, 12:36:14 pm »
I'm currently developing a game on my laptop (resolution 1024x768) and today when I tried running the game on my other computer (resolution 1280x1024) all graphics were drawn at the top 1024x768 pixels and not stretched to fit the screen which I was hoping. Is it possible to stretch to fit the screen? I'm using full screen mode.

12
Feature requests / Outlined text
« on: June 25, 2008, 12:08:43 am »
Is that something that could be implemented in the future? Don't know if it's possible but it doesn't hurt to ask ;)

For example in my game I have white text and occasionally the background becomes partly white which makes the text invisible. Having white text with a black outline would fix this. I guess I could draw a black rectangle behind the text but that's the last option.

13
Graphics / [Solved] Gradient
« on: June 22, 2008, 01:09:50 pm »
How do you draw a sf::Shape with a color gradient? Let's say I want a rectangle with a red top and a blue bottom. Would be interesting to know the math behind the color calculations.

14
Graphics / [Solved] Draw only a part of the sprite
« on: June 17, 2008, 08:31:24 pm »
Is it possible to draw only a part of the sprite, for example the bottom half?

If not, will it be in the future?

15
General / [Solved] Designing questions
« on: June 13, 2008, 08:21:34 pm »
I'm not sure this fits here, if not please move it.

As my project grows there are functions across multiple files who need access to the renderwindow instance, what is the best way to do this? Have a global instance, or to pass a reference to the instance to each function needing it?...or?

Another thing, I draw a lot of text in my project and right now I only have one sf::String instance where I use the setText-method each time I need to draw a new thing which also means setting a new position, a new center etc. It quickly becomes a lot of setting and getting and I'm wondering if this is an expensive and poor way of doing things?

Creating small projects where everything can be in one file is not hard it's when things get large these designing questions occur especially if you haven't got a lot of experience so any designing tips are welcome.

Pages: [1] 2
anything