SFML community forums

General => SFML projects => Topic started by: kolofsson on April 20, 2010, 11:54:40 pm

Title: Screenway - a racing game
Post by: kolofsson on April 20, 2010, 11:54:40 pm
Hello there. I finally started my first project. It is going to be a racing game. At the moment there is only one car that can be driven over a surface with no collisions. I made it using VS 2010 and SFML 2.0 snapshot. The VC 2010 dll's are included in the package, so it should run out of the box.

Link:

http://grebocin.com/upload/screenway08.zip

Controls:

steering - arrows
gear up - A
gear down - Z
toggle vsync - F1
zoom in - NUM+
zoom out - NUM-

List of changes:

rev 8 (2010-04-24) - added rev meter and a timer
rev 7 (2010-04-22) - added zooming
Title: Screenway - a racing game
Post by: Nexus on April 21, 2010, 04:15:22 pm
Hi,
Your game doesn't work at me. I'm using Windows 7 (32 Bit). When I start the application, a white screen appears for one second, nothing more.

However, the provided image looks quite nice. ;)
Title: Screenway - a racing game
Post by: pierreyoda on April 21, 2010, 09:19:31 pm
Can we have screens please?
And what SFML version do you use? :D
Title: Screenway - a racing game
Post by: Ashenwraith on April 21, 2010, 10:11:49 pm
It doesn't work here either.

It's probably because his texture is currently too large for your gfx cards.
Title: Screenway - a racing game
Post by: kolofsson on April 21, 2010, 10:22:15 pm
Yes guys, the track is too large, and SFML supports only sprites as big as the largest texture your graphics card supports.

I have GeForce GTX 260, which supports textures up to 8192x8192, so the game works for me. I will try to find a way to make it work.

And, as I wrote, I am using SFML 2.0.

Most graphics cards support textures of 2048x2048, so if you crop the image montmelo.jpg to this size, the game should work.
Title: Screenway - a racing game
Post by: Ashenwraith on April 21, 2010, 10:37:39 pm
Scaling your images in game is tricky to make them look good and best avoided in a simple game (there is a certain pattern of resolution created by evenly divided by 100).

The track looks too blurry, I wouldn't scale it.

The car should be scaled beforehand so it's smooth.

I would also try picking a car that doesn't look like it's covered in pebbles.
Title: Screenway - a racing game
Post by: kolofsson on April 21, 2010, 10:51:30 pm
Quote from: "Ashenwraith"
Scaling your images in game is tricky to make them look good and best avoided in a simple game (there is a certain pattern of resolution created by evenly divided by 100).

The track looks too blurry, I wouldn't scale it.

The car should be scaled beforehand so it's smooth.

I would also try picking a car that doesn't look like it's covered in pebbles.


Dear Ashenwraith

I only scaled the image to make the road big enough for the car, to test how it behaves.

The car is bigger, because later on i will add speed dependent zooming, like it was in GTA 1 (you drive slow, the car is bigger, you drive fast, you see more of the track).

Besides, if I enable anti-aliasing the quality will improve a lot.

And finally, the textures aren't what matters now. I only chose this track and this car, cause I didn't have to make them myself. When I work out the physics, I will take care of the graphic side

Any way, thanks for the input  :D
Title: Screenway - a racing game
Post by: Ashenwraith on April 21, 2010, 11:00:54 pm
Anti-aliasing is not going to improve a 32bit png...
Title: Screenway - a racing game
Post by: kolofsson on April 22, 2010, 12:47:38 am
OK guys, I cut the image into pieces of 2048x2048. Hopefully, everyone will be able to run it now.

I also added zooming, NUM+ and NUM- are responsible for it.

http://grebocin.com/upload/screenway_r7.zip

I really hope it works now! However, now you can find these black lines between the tiles. I don't know why they appear, as the tiles are perfectly matched...
Title: Screenway - a racing game
Post by: Breakman79 on April 22, 2010, 01:13:07 am
Have you tried disabling the bi-linear filtering on the background images?  It seems to be a very common issue that people have when first starting out.

image.SetSmooth(false)
Title: Screenway - a racing game
Post by: Ashenwraith on April 22, 2010, 02:18:48 am
1024x1024 is a much more standard size and if you want old gfx cards you should do 256x256
Title: Screenway - a racing game
Post by: pierreyoda on April 22, 2010, 10:24:12 am
I tried the game : very nice !  :D
I love the car's physic, with lot of inertia  :P
Title: Screenway - a racing game
Post by: kolofsson on April 22, 2010, 10:57:55 am
Quote from: "Ashenwraith"
1024x1024 is a much more standard size and if you want old gfx cards you should do 256x256


um, so youre saying I should slice my track image into:

(6 500 * 2 400) / (256 * 256) = 238.037109

about 238 pieces? hmm... maybe you know some library that could load big images to memory and then extract only parts of the image, so I could feed the sf::Image::LoadFromMemory or LoadFromPixels.

this is complex stuff, I'm quite surprised that it isn't covered by the library.

Quote from: "Breakman79"
Have you tried disabling the bi-linear filtering on the background images? It seems to be a very common issue that people have when first starting out.

image.SetSmooth(false)


yes, it worked! thank you! however, now the track does not look so nice when it is upscaled.

Quote from: "pierreyoda"
I tried the game : very nice !  
I love the car's physic, with lot of inertia  


thanks. Remember, this is just the first thing I decided is worth showing. It will see many improvements, like drifting for example.
Title: Screenway - a racing game
Post by: Ashenwraith on April 22, 2010, 11:23:44 am
Quote from: "kolofsson"

um, so youre saying I should slice my track image into:

(6 500 * 2 400) / (256 * 256) = 238.037109


The extra is loaded with a bg color or transparency.
Title: Screenway - a racing game
Post by: dabo on April 23, 2010, 12:29:58 pm
The game just closes when I try to start it; I can see the window showing up for a second. Perhaps it is because of my crappy integrated Intel graphics.

The images look great, was looking forward to trying it out.
Title: Screenway - a racing game
Post by: pierreyoda on April 23, 2010, 09:53:45 pm
Hey, just a question : how do you get that zoom effect?  :D
Title: Screenway - a racing game
Post by: kolofsson on April 24, 2010, 10:25:05 am
Quote from: "pierreyoda"
Hey, just a question : how do you get that zoom effect?  :D


Code: [Select]
dt = window.GetFrameTime();
if (window.GetInput().IsKeyDown(sf::Key::Add)) view.Zoom(1.f - dt);
if (window.GetInput().IsKeyDown(sf::Key::Subtract)) view.Zoom(1.f + dt);
Title: Screenway - a racing game
Post by: kolofsson on April 24, 2010, 10:38:08 am
I uploaded revision 8. Now you can race against time. The timer starts when you start moving. It stops when you cross the finish line. My record time without going out of track was 64.0 seconds. Try to beat that!  8)