Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Apr 2010
Online Last Active Today, 03:22 PM

#5316891 Monogame make player follow mouse

Posted by on Today, 01:22 AM

It's called whenever the left mouse button is pressed.

Then why are you checking the button state? You're showing code that doesn't appear to contain a bug. If you want help to find the bug you need to provide more context. If you're like most of the people who swing through the FB forum you'll respond to this by telling me a very long story that only contains information that I don't need, then I'll get frustrated and leave. Please post all of the relevant code instead.

After testing it again it seems like the movement direction is the last direction the mouse moved and not towards the mouse.

Try printing the mouse and player coords to the screen every frame. Spidi is probably on the right trail, since it would generate that kind of behavior; if the player is at the indicated location and then the mouse moves then the direction to the new indicated location will be the direction that the mouse moved.

#5316458 How should my Networking class send and receive info from my other classes?

Posted by on 24 October 2016 - 08:29 AM

Prefer std::unordered_map (over std::map) in all cases where strict ordering is not required (most cases).

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

Posted by on 21 October 2016 - 05:02 PM

Would this help?





#5316024 Unity Software Architecture - how to make reusable UI classes that inherit fr...

Posted by on 20 October 2016 - 10:52 PM

I feel like I'm missing critical info here, but in general I wouldn't bother. This smells like over-engineering, but I also suspect that it's possibly motivated by mis-estimations of canvas.

How many uniquely coded UI elements do you really need to tamper with?

If you're doing something unusual then more information is necessary to answer questions about how to structure it. If you're not then look closer at what's available from the engine to makes sure you're not reinventing the wheel or missing some more concise way to do what you need.

#5315904 c++, passing std::container without template

Posted by on 20 October 2016 - 01:13 AM

They are not polymorphic, so no. You either have to template or just write every allowed overload.



for(auto it=c.begin();it!=c.end();it++) {

can be

for(auto&& thing : c) {

#5315872 C++ - win32: can i change the menu font?

Posted by on 19 October 2016 - 03:20 PM

The WM_SETFONT message can set the font of a specific window.

#5315842 Rendering an object with multiple subsets

Posted by on 19 October 2016 - 11:14 AM

Good luck?

#5315841 Alternative book(s) to Introduction to Game Development

Posted by on 19 October 2016 - 11:12 AM

It's possible that he's looking for the book that will help him to figure that out. I think that such books have probably been replaced by engine tutorial videos at this point. Going through the Unity and UE4 tutorial series (and doing the exercises) should give you the lay of the land from the high-level perspective and then you can look closer at whatever interests you.

#5315573 List out of bounds in for statement with range maximum equal to length of lis...

Posted by on 17 October 2016 - 12:38 PM

The for loop I quoted in the original post is in the programs main loop (not a thread)

If it's not in a thread then it's not running on a computer. Your program starts in a thread and may or may not spawn additional threads. If you want a mutex (a "lock") to work then you need to acquire the lock before accessing the shared resource from anywhere and remember to release it when you're done in every case.

#5315208 UML diagrams for video games

Posted by on 14 October 2016 - 10:02 AM

UML is a massive waste of time. It's designed for overzealous bureaucrats so that they can draw stick figures all day in order to make sure that no actual work accidentally gets done.


The best part about UML is that the people involved with it think that "standardized" simply means, "Just do it my [highly technical] way." Since it's exposed to the whole wide world of bureaucrats and academia that means that there are actually about a a hundred different "standards" for every person who has ever used it, which in turn means that no matter how you do it you're going to be "wrong" to pretty much everyone in the world, including yourself, and the ways in which you are wrong make no sense to anyone in the world.


Thus you need to review whatever text or guide your professor has provided and follow that as closely as you can, since it's probably at least vaguely similar to whatever protean gibberish serves as a standard for your case. If you're very lucky then they're asking for class diagrams, which is basically a way of writing a C++ header that takes 50x longer and doesn't run the risk of being worthwhile, since you can't compile it. If you're unlucky then they're asking for use cases, which is a way of masturbating in public without being arrested. In that case you may as well just get it done and over with and look at the syllabus to see if you can make up the points elsewhere. If the assignment doesn't bear any significant weight then an example use case is this:

uml diagram.jpg

As braindigitalis mentioned, this is not a real-world tool unless you're planning on working for "THEM", so please forget whatever they've told you about it as soon as possible, wash your hands thoroughly, and go back to just writing in plain language and free-sketching ASAP.


#5314371 I need 3d animated characters and environments to practice with

Posted by on 08 October 2016 - 08:25 PM


#5314024 Passing data between states in an FSM

Posted by on 05 October 2016 - 12:06 PM

I'm curious about what kinds of parameters are being handed around between states. I know that there are sometimes trivial things like having a menu state return to a previously selected index (where a state stack makes a ton of sense) but generally my states don't need a lot of initialization information beyond, "Hey, wake up. It's your turn."

#5314021 Getting more curious and curious

Posted by on 05 October 2016 - 11:53 AM


#5313632 How to implement a object manager class?

Posted by on 02 October 2016 - 04:58 PM

LSP basically means that if S inherits from T then you should be able to say:


T* derp = new S;


and then 'derp' should behave 100% correctly as a T, because if you're using inheritance correctly then derp is-a T, even though the underlying type is S. If you enforce LSP in cases where inheritance is not necessary then the parent type usually ends up looking pretty worthless.


Before using inheritance:

  1. Do I need polymorphism here? Is polymorphism the best way to manage this?
  2. Does the derived type satisfy the is-a rule for the base type? In the sense that it does, is that really the best way to handle these objects?
  3. If I cast a derived object to the parent type can it behave correctly in all cases?
  4. Is there a reason that I can't use composition? (Hint: usually no)

If you can't meet all those qualifications then there's probably a better solution. It's usually composition.



/* BAD */
class LocationalThing {
  float x, y, z;

class Entity : public LocationalThing {
/* LESS BAD */
struct Location {
  float x, y, z;

class Entity {
  Location position;

Note that both cases provide the same basic functionality, but you avoid all of the problems associated with inheritance (diamond of death, etc) and you have a convenient package for handing around position data. Locality is an attribute of entities, not a category that entities fit into. Continue following this logic and soon your need for an Entity class will start to be suspect. Eventually you'll realize that inheritance makes it easier to operate on a series of objects that share some set of attributes through polymorphism.


For example, if you have several different graphical types, like Sprite, Circle, Mesh, etc., they can probably all have a draw function, and you probably want to draw them all around the same point in time, so you may want them to inherit from an abstract class RenderObject that declares the draw function. This way you can place them in a single list, sort it, and then iterate it and draw them all in one go. The danger here is that you want to draw a new type of thing in the future, but it doesn't quite fit with the RenderObject signature, so you have to change RenderObject, which means that you have to change all of its derived types, which means that you should start considering another way of managing it.

#5313597 How to implement a object manager class?

Posted by on 02 October 2016 - 11:42 AM


Some of those errors are a little strange.   Check what happens if you remove the implementation from Entity.cpp and instead write an inline implementation inside GetType() within Entity.h.    Also have you implemented the GameObject and Sprite versions?


Sorry, my bad. For some reason I added Entity::GetType() instead of GameObject::GetType() in my GameObject class.

But I think it's working now! It's messy but working.

I'll go ahead and research on a component system as well, however I don't think I'm going to add it until later on.


Thanks a lot for the help though!




Two classes that derive from Entity is Sprite, GameObject.







But a GameObject is a entity?? D':



It could be argued that "game object" is actually the definition of "entity", but in any case sprites are not entities.


You've leaning way too heavily on inheritance here. In addition to the is-a/has-a thing, there's no way that you're observing LSP:



Inheritance should only be used to facilitate polymorphism. Prefer composition strongly.