Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Oct 2013
Online Last Active Today, 05:58 AM

#5316166 Attempting a proper 2D game engine, always find myself out-of-scope

Posted by on 21 October 2016 - 07:26 PM

In my programs I have only ever included .h files, never .cpp

Include the .h files, but include them in .cpp files when possible.


Forward declare when possible, include when you must. Look up forward declaring if you're not familiar with it.


Your master class sounds like a bad idea. It sounds effectively like a global, which is generally considered a code smell. If everything can access and talk to everything else from anywhere, tracking code flow becomes a huge issue as the project grows.

#5315856 Rendering an object with multiple subsets

Posted by on 19 October 2016 - 01:21 PM

Do you have any idea why this is happening?

If it shows up twice, you're rendering it twice. Why is anyone's guess without code access.


My suggestion is to just put a breakpoint in the render function and see where it's being called from.

#5315153 Why is visual studio giving me a bunch of false errors?

Posted by on 14 October 2016 - 06:30 AM

All my headers files have #pragma once in them though, is it still possible to create a circular dependency?




If class A contains an instance of class B, and class B contains an instance of class A, you will run into problems, unless you can forward declare some stuff.

Only include in header files if you need to. If you can get away with forward declaring in headers and including stuff in the .cpp files, that's A Good Thing™.

#5315083 Next Step

Posted by on 13 October 2016 - 05:53 PM

You were working on a game (previous post), and you shelved another one.

Try continuing one of those, and taking it to completion.

#5315008 Improving collision query?

Posted by on 13 October 2016 - 10:34 AM

As others have noted, it doesn't look like there's currently any performance issue, so this should be fine.

Mind me asking what the down-vote was for? =)


EDIT: Explained via PM that it was a misclick. No worries!

#5314972 Improving collision query?

Posted by on 13 October 2016 - 06:22 AM

There's probably no need to worry about it right now if there isn't a performance issue yet.

What you can do is to not check collision against every other object. Do some spatial partitioning and you can cut down the amount of objects to check against drastically.


Example: Divide world intro collision grid, only check against objects in same collision grid cell (and maybe the ones close in case of border crossing).

#5314817 Get direction of a ship base on where the booster is position?

Posted by on 12 October 2016 - 04:47 AM

I'm not quite sure what you're asking, but I think you can just do Direction = Normalize(BoosterPostion - ShipCenterOfMass). Center of ship could be either just the middle of the ship, or offset to cause over/understeering.


EDIT: My suggestion does not take into consideration any rotational component based on having the booster on one side of the ship (basically assumes booster fire direction is always directed to prevent it).

Also -- ninjaed by BBeck.

#5314571 Designing everything then Program it later - is this a good plan?

Posted by on 10 October 2016 - 02:52 PM

Not really. Design the large-scale things, then start implementing as you go.


If you try designing everything to the smallest detail, it's very likely you'll encounter something when you code it up that makes you go "Huh, this didn't really work at all as I had thought. I'll need to change this and everything related to it".


Have a plan, then create small tasks (say 1-2 weeks of work), then implement as much as you can. After the task is done, look at where you are and create new tasks. Repeat until done.

#5314453 A bunch of really stupid code-structure questions.

Posted by on 09 October 2016 - 02:54 PM

I did see a really great post on here about splitting up your ResourceManager but I really can't recall where it was

Probably this (or containing basically the same information):


See haegarr's post especially.

#5314269 Grid Based Block Placement

Posted by on 07 October 2016 - 11:11 AM

There is a more efficient way to calculate what you are after, you basically want the closest larger multiple of the block size to the current number:

The code you posted does not give the same results in all cases, e.g. playerPositionX = 0.

In the original case, blockPositionX would be 0, in your case it's BLOCK_SIZE. You always round up, even if it's already correct.


The following works, though:

blockPositionX = BLOCK_SIZE * ((playerPositionX + (BLOCK_SIZE - 1)) / BLOCK_SIZE);
blockPositionY = BLOCK_SIZE * ((playerPositionY + (BLOCK_SIZE - 1)) / BLOCK_SIZE);

#5314265 Bringing Blocks To The Background?

Posted by on 07 October 2016 - 11:04 AM

This causes about a decrease of about 200-250 fps

This means nothing. Frame rate reducing by x frames is completely useless as a metric to go by.


Unless your current performance is actually a problem, ignore it and move on to the next task. You can always optimize things later if there's a need for it.

#5313771 Specfic AI scripting question

Posted by on 03 October 2016 - 01:52 PM

You could do that, but it's better to separate things into their own "blocks" when you can.

It will likely be less code in total, and if there's a bug with a spawned zombie, you know that the normal NPC code doesn't have anything to do with it (it doesn't even exist for the zombie!).

It also means that you're able to make humanoids spawn into other things more easily -- e.g. there's a 1/10 chance that it spawns a super-zombie (which is also a unique type).

#5313598 Looking for (mmo)rpg tutorial

Posted by on 02 October 2016 - 11:43 AM

I would skip anything online related for now, based on your current experience/skill level.


Also, unless you have a huge team, or enough money to hire a huge team, forget anything related to MMO.

(Note that MMO and online are completely different ballparks. A "normal" online game supporting 4-8 players is one thing, an MMO game supporting tens/hundreds of thousands concurrent users is a completely different beast.)


A simple singleplayer RPG might be doable, as long as you keep things simple and basic.

#5313378 When should I use int32_t rather than int

Posted by on 30 September 2016 - 07:36 AM

for( auto end= someVec. size(), i =end *0;i<	end; ++i) {
 if (!someVec[ i] .invalid () !=false ) {
Nailed it.

L. Spiro



I think this should be a part of your mandated coding guidelines (as per your other thread).

#5312930 target selection strategies

Posted by on 27 September 2016 - 05:08 PM

If the behavior "makes sense" to the player, we have succeeded.

It's worth noting that what makes sense to the player is something we can (to a certain extent) teach the player during the game.


Imagine a few scenarios:

You're surrounded by enemies, and they all suddenly take cover without warning just before a thrown grenade explodes.

You stealthily take out a guard in a far-off location. As you're looting the corpse, 15 other enemies show up.


Both of those could feel very unfair to the player -- the AI is cheating!


Now imagine the same scenarios, but imagine they are telegraphed to the player.

One of the enemies shout "Fire in the hole!" right before the group of enemies take cover.

You hear radio chatter on the corpse's walkie-talkie, which sounds more and more distressed, before the rescue party shows up.


The AI didn't need to change, but now the game feels a lot more clever, because we've been more explicit in telling the player something which makes the actions make sense to them.


Of course, this isn't always wanted or beneficial, but it's definitely worth keeping in mind.