Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Mussi

Member Since 12 Oct 2004
Online Last Active Today, 08:57 PM

#5118105 SDL Pong paddle issues

Posted by Mussi on 19 December 2013 - 07:29 AM

Instead of trying to keep your fps constant(which is not what's happening) you should move your paddle in proportion to the frame time.

 

Some problems I saw by glancing over your code:

  • You're frames per second calculation calculates the average fps for the entire duration of the game, you probably want to reset your frames counter when at least a second has passed. To correctly estimate the fps, you should divide your frames by currentTime - lastTime.
  • Your condition to call SDL_Delay is always true, SDL_GetTicks() - currenTime will practically always be 0.
  • 1000 / MAX_FRAMES will result in an integer instead of a float, resulting in 16 instead of 16.66.., this is a significant loss of accuracy.
  • Don't use the #define preprocessor to define constants, use const values instead.

Keeping fps constant is not easy if not impossible and what happens when a device can't make it past 30 fps? Your game will run at half the speed.

In order to move the paddles and the ball at constant speeds on varying frame rates you simply multiply the movement by the delta frame time(time difference between current and previous frame).

 

There is another thing you need to be aware of, most timers aren't nearly as accurate as you might think. Depending on your frame rate and the accuracy of the timer, you might not be able to detect a difference in time between two frames, i.e. delta time becomes 0. I'm not familiar with SDL so I don't know how accurate SDL_GetTicks() is(a quick search indicates it's about a millisecond), so you might have to use a more accurate timer.




#5114066 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 10:03 AM


Yes I know that Ogre is just a graphics engine. But it have "Addons" for OpenAL, ODE, CEGUI and etc.

What do you recommend then, apart from C4?

Setting up those libraries to work with Ogre3D isn't as simple as downloading and installing an add-on for some software. I recommend you go for a game engine that satisfies most of your needs in order to create the game you want to create. Why would you put together bits and pieces to create something that you already know you want, a game engine.




#5114047 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 09:11 AM

Ogre3D is just a graphics engine, you'll need different libraries for sound, physics, GUI, etc. I don't recommend it if you just want to get started on creating a game.




#5114022 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 07:46 AM

Have you taken a look at the C4 Engine? It's not free but it's a great engine with almost all the features you need(no lua or javascript based scripting), plus you get access to the source code. The community is also very active and helpful.




#5112085 std::string causing crashes!

Posted by Mussi on 26 November 2013 - 02:50 AM

In addition to what Brother Bob said, never use malloc in C++. Not only does new ensure that constructors are called, it's also more type safe and the C++ way of allocating memory.




#5108002 Looking for feedback on UI components (Video)

Posted by Mussi on 08 November 2013 - 07:24 PM


I'm not exactly sure what to multiply though, as it feels like the resulting INT may be out of bounds, and the integer value doesn't seem to have an easy way to refer to HSI or RGB?

You can extract RGB values by using bitshifts and bitmasks. You can find find tons of information on how to extract these values and put them together again out there, so that shouldn't pose a problem. However, I don't think you need to go that route. Looking at the StageXL library, you could probably use colorTransform() on a BitmapData object and pass the multipliers I described earlier.




#5107221 Looking for feedback on UI components (Video)

Posted by Mussi on 05 November 2013 - 01:18 PM

That said, my limitation with multiply blend isn't the actual implementation/syntax, but I'm unfamiliar with the concept. A quick lookout on wikipedia didn't reveal much. Do you have an example of application?

Sure. Going from left to right, the opacity of the redness is 100%, 50% and 25%. As you can see(or might not) the 25% isn't that visible so you might want to scale from a 100 to 25% or not linearly at all.

multiply.jpg

 

I'm guessing I need to do maths on specific pixels (the one on top and the one underneath?).

 

You can simply multiply the green and blue value of each pixel in the ship by it's health ratio. I'm not sure if you can manipulate the rendered pixels or have to create a new image from the original.




#5107157 Looking for feedback on UI components (Video)

Posted by Mussi on 05 November 2013 - 08:16 AM


Here's what I did:

Added Red Masks (the ship turns to red as it takes damage)
Added Shields (the shield fades as it takes damage)

You forgot explosions, you've got explosions now! Great progress :). I personally like vanilla the most.

 


Very accurate. I actually put it up as one of my notes on our Trello. The one reason I kept it as is for now is that full saturation is simple to understand, there's no doubt when the ship will break. 50% alpha will look arbitrary, and will take some getting used to for players to anticipate the "full damage" with an incomplete transition.

What about using a multiply blend? Multiply the green and blue color component with health ratio.




#5106015 Looking for feedback on UI components (Video)

Posted by Mussi on 31 October 2013 - 12:03 PM


Yes, I understand, thanks.

Not sure if that would be necessary though, and it kind of breaks the pace of the gauge?

It depends on the importance of hit point levels(e.g. there are special things you can do when a ship is below 25%). If this is not a factor at all than I think you should stick to what you have.




#5105937 Looking for feedback on UI components (Video)

Posted by Mussi on 31 October 2013 - 07:00 AM

Do you mean like, vertical yellow bars across the gauge to segment it?

 

 

Yes, though I did not have yellow in mind tongue.png. Here's an example:

gaugetry.jpg

 


It could look odd if some weapons' cooldown were accounted for and others weren't?

Also, I'm anticipating that most weapons will take 2+ seconds to reload. The values I'm using right now are simply random because I didn't get around to creating the external XML balancing document yet for these.

My thought was that there'd be at least two categories of weapons, one that fires rapidly(think pew pew lasers) and one that takes a significant time to charge/reload(seems like your rockets belong to this category). The rapid fire category wouldn't be that interesting to display the charge bar for.

 

Alternatively you could use circular gauges for each weapon, you could colorize these by weapon type as well without getting a rainbow bar effect.




#5105834 Looking for feedback on UI components (Video)

Posted by Mussi on 30 October 2013 - 07:20 PM

In addition to the improvements you've made, I'd make the life bar slightly higher and add markers for 25%, 50% and 75% (this will also allow you to reduce the width of the bars without them becoming hard to read). Also, I'd get rid of weapon charge bars for charge times < 1 or 2 seconds.

 

Looks awesome so far, keep up the great work!




#5085312 Vector hell!

Posted by Mussi on 12 August 2013 - 05:02 PM

Y - X

Normalize the result so that you can scale it to a precise length afterwards. You can normalize a vector by dividing each component by the length of the vector. You can calculate the length of a vector as follows: sqrt(x*x + y*y + z*z), where x, y and z are the vector's components.




#5084848 EventBus - Possible with C++ templates?

Posted by Mussi on 10 August 2013 - 09:54 PM


{
handlerMap.insert(
   id,
   [=]( AbstractEvent* ev )
   {
      cb( *(EventType*)ev;
   }
   );
}

 

I'd personally format this as:

handlerMap.insert(id, [=](AbstractEvent* ev)
{
	cb( *(EventType*)ev );
});

This might make it clearer for you. Combined with less obscure variable names you might even start liking it smile.png.




#5073968 Circular buffer usage

Posted by Mussi on 29 June 2013 - 12:52 PM

Lets say you have a game with a rewind functionality, where your character can travel back in time. You'll most likely have a cap on how far one can rewind. At any point in time, you'll have to know the x steps taken before the current step. Now imagine how easy this becomes with a circular buffer smile.png.




#5065368 std::bind and function

Posted by Mussi on 27 May 2013 - 05:28 PM

No, your say function isn't printing anything.

 

Edit: Got beat to it!






PARTNERS