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

Pages: 1 ... 7 8 [9] 10 11 ... 34
121
Graphics / Re: Vector of structs which contains sprites
« on: February 08, 2020, 11:04:35 pm »
You're experiencing the white square problem. In this case it happens because you attempt to store the textures in a vector. Pushing an object into a vector will cause the vector to resize (if a specific size has not been reserved) moving everything the vector holds around in memory, which is why all but your last sprite appears white. Generally some sort of resource management is used to hold all your textures/shaders/audio buffers so that they can then be shared with any game entities that use them. The SFML Game Development book has a good example of how to do this.

122
Graphics / Re: Image Stretch with window resize
« on: January 29, 2020, 12:33:57 am »
A custom sf::View is the way to go. This wiki article might explain it better: https://github.com/SFML/SFML/wiki/Source%3A-Letterbox-effect-using-a-view

123
Thanks! I think the explosions could be best improved with perhaps a decent sprite animation rather than just particle effects. The particles, as you say, would make nice smoke. Shadows are a nice idea, I'd have to think about how to do them. Projection/shadow map shadows don't work so well in 2D, particularly when the light source is to the side of the sprite as there's no depth to cast a shadow :) I had a similar issue when working on my pirate game:

http://youtu.be/30wvsDwAKHs?t=192

124
It's been a while but there's a new update to 1.4!



Changes include:
  • All new renderer featuring 3D effects and real time lighting
  • New animations
  • Improved physics
  • Many bug fixes and performance improvements incorporated from the latest version of xygine
  • New steam features such as network play via remote play together and rich presence
  • Updated game play with added high score challenges and time trial leaderboards
  • New enemies and bonuses
  • More achievements

For more information, check out the Steam page  ;D

125
General / Re: Direction of collision
« on: January 20, 2020, 11:01:18 am »
You need to calculate what's called a 'collision manifold', which not only tells you the direction of the collision but also the amount of overlap. This can be done relatively easily with circles and AABBs (see here) - for non-square shapes SAT (separating axis theorem) is a common approach. Once you have your manifold how you react to the collision is up to you :)

126
Graphics / Re: How to move a sprite in a fixed range?
« on: January 05, 2020, 11:48:31 am »
You can do this by adding a velocity property which dictates the speed and direction of your sprite.

struct MyThing final
{
    sf::Sprite sprite;
    sf::Vector2f velocity;
};
 

Set the velocity y value (the direction you want to move) to a certain amount, eg: 10 which will be the number of units it moves per second. Move the sprite by this velocity multiplied by the elapsed time:

while(window.isOpen())
{
    //handle events here

    sf::Time elapsed = clock.restart();

    myThing.sprite.move(myThing.velocity * elapsed.asSeconds());

    window.clear();
    window.draw(myThing.sprite);
    window.display();
}
 

This will move the sprite in a straight line as defined by the velocity. To make it change direction add a position check after the sprite has moved:

auto position = myThing.sprite.getPosition();
if (position.y < 0)
{
    //clamp the position to the bounds
    position.y = 0;
    myThing.sprite.setPosition(position);

    //reverse the direction
    myThing.velocity.y = -myThing.velocity.y;
}
else if (position.y > 352)
{
    //see above
}
 

This post offers a more detailed explanation: https://medium.com/@swiftsnippets/vectors-position-velocity-and-direction-b85342ed9e3a

127
Graphics / Re: Pixel Offset when drawing images
« on: January 05, 2020, 11:26:35 am »
Rather than draw the same sprite over and over, you could set the texture to repeated, then set the sprite texture rect to the size of the text box. The texture will automatically repeat to fill the sprite.

Alternatively there is the 9 patch method, used a lot in UIs: https://github.com/Hapaxia/SelbaWard/wiki/Nine-Patch which might do a better job for what you want

128
SFML projects / Re: Intel 8080 Emulator-Space Invaders
« on: January 05, 2020, 11:16:53 am »
Nice work! I made a space invaders emulator some time ago based on the tutorial at http://emulator101.com/ - like you I experienced frustratingly difficult to debug crashes :( I also discovered that the arcade hardware was similar enough that the emulator can also run Balloon Bomber and Lunar Rescue!

129
General / Re: SFML books - reading order?
« on: December 22, 2019, 11:20:14 pm »
FWIW the first book I read was SFML Game Development (Artur Moreira, Henrik Vogelius Hansson, Jan Haller) and I found it easy to understand and overall an enjoyable experience. It covered an entire project from start to finish and was the first book that really helped me understand how SFML was designed to be used. I've also tried reading SFML Essentials (Milcho G. Milchev) and SFML Game Development By Example (Raimondas Pupius), although, to me, they felt slightly less well structured and used programming syntax/conventions which I found hard to digest - although I admit some of that may be due to personal coding preference. As a secondary/supporting book I'd actually recommend Game Programming Patterns (Robert Nystrom) as I found it accessible and a good reference for implementing my own ideas when trying to extend what I'd learned from SFML Game Development. https://gameprogrammingpatterns.com/

130
General / Re: Rendering ObjectLayer using tmxlite
« on: December 22, 2019, 11:08:44 pm »
Hi!

I'd recommend first checking out the quickstart to get the object layers from your map, followed by the objects in each of those layers: https://github.com/fallahn/tmxlite/wiki/Quick-Start

Once you have your objects you can parse them as you'd like, using the object properties available (reference here: https://codedocs.xyz/fallahn/tmxlite/classtmx_1_1Object.html )

For example you'll probably want to use getPosition() and getRotation() and then use, for example, getAABB() to draw the object bounds with an sf::VertexArray set to LineStrip or getTileID() to grab a tile from your tile set and draw it with sf::Sprite. You could also use getShape() and getPoints() to draw the object with a LineStrip, or getText() if the object has text which could be rendered with sf::Text.

HTH!

131
General / Re: Collision detection: two identical cases - how to solve?
« on: November 24, 2019, 11:02:12 pm »
This can be solved by calculating a 'collision manifold', which describes from which direction a collision occurs. I wrote a short SFML specific article about it here. There are a few more resources linked at the bottom too.

132
SFML projects / Re: OSGC - Open Source Game Collection
« on: November 19, 2019, 10:36:46 am »
Hehe, thanks, but I wouldn't rank them as 'great' particularly. In fact I'd only consider 2 of them finished, Drone Drop and Desert Island Duel, and even then Drone Drop could use a few more maps. Desert Island Duel has been in the works for nearly two years now, on and off, I just didn't publish much about it originally as I had planned it as a Steam release. I'm actually much happier to have it open source now though :)

133
SFML projects / Re: SFML Gameboy Emulator
« on: November 10, 2019, 09:33:00 pm »
Ah! That's a much more practical approach. I'll definitely have to try that next time I work on something similar - I'm by no means a purist and would much rather get good results :D

134
SFML projects / Re: SFML Gameboy Emulator
« on: November 10, 2019, 10:49:11 am »
Nice work!

How did you handle the audio with SFML? When I did mine I had real trouble keeping the audio in sync/at the right speed due to the sample rate effectively being that of the emulated CPU speed. I ended up resampling the output and sent it to the soundcard via SDL because it gave more direct access to the audio hardware. Would be nice to drop the dependency and use only sfml! :D

135
SFML projects / Desert Island Duel - Open Source Game Collection
« on: November 02, 2019, 12:42:10 pm »
I've just updated the itch project page with downloads for Desert Island Duel



This is a 1-4 player online treasure hunting game, where each player fights to dig up as much treasure as possible. More gameplay details are available on the project page, and as always the source is on GitHub :D

Pages: 1 ... 7 8 [9] 10 11 ... 34
anything