Object-oriented programming. A paradigm using objects (instances of a class consisting of properties and methods) to design games. Techniques may include data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.
2
votes
1answer
53 views
Behaviours: Should I always return a reference to the behaviour on its methods? [on hold]
I'm writing a small game to sharpen my programming skills, and I've chosen to use behaviors (that basically is a class that modifies its parent, to do things like movement, damage and stuff) to avoid ...
1
vote
1answer
47 views
How to minimize the repetitive creation of component in libgdx ashley?
The below example is creation of character Entity. My problem is do I always need to call these engine.createComponent(...class) to create a component? Or should I wrap these to another class that ...
1
vote
1answer
44 views
Deriving from base class but not calling base method
I am very new to C#, XNA, and OOP. This is my question: I have an abstract class called Sprite. Sprite handles position and drawing from the sprite sheets, from its update and draw methods, for my ...
0
votes
1answer
29 views
libgdx - Should I use OOP in ECS framework? [closed]
For example I have OOP class of Bullet and I have created the pool and factory. Should I convert it to componet based? Like BulletComponent, then handle by BulletSystem? by the way I'm using Ashley ...
1
vote
1answer
104 views
Designing PHP RPG game: Should I use multiple classes for each type of item or a single table?
I'm making a text-based role playing game written in PHP.
I have a hard time figuring out how to handle items in game - there will be a few types of objects (weapon, machine, tool, building etc) each ...
0
votes
0answers
35 views
Making unity inspector accept classes that inherit from a base class
I have a base class that has a lot of classes inheriting from it, I want to make a script that you can drop one of these derived classes into. How do i do that?
abstract class thingy : UnityEngine....
0
votes
1answer
95 views
Organizing Setup(), Update() and Draw() function in a game engine
I'm creating my first game engine and I want help with organizing the Setup(), Update() and Draw() functions in the correct way.
Here is how my main() function looks like
/* BEGIN main() Function */
...
2
votes
2answers
181 views
Cost of Using Virtual Methods to Query Properties?
Let's say you're making a tile-based roll-playing game, and you're obsessed with OOP.
You have an abstract base class Tile which will be inherited from by many derived classes, like Grass Sand and ...
16
votes
6answers
4k views
How do I correctly use singletons in C++ engine programming?
I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one.
The problem is, to draw ...
4
votes
4answers
177 views
Better way of handling the relation between Bullet and Enemy
I was wondering how should I design this relation in terms of "better OOP"?
Should I have a Singleton EnemyManager which contains a list of enemies (EnemyList); then Bullets can access the EnemyList ...
3
votes
1answer
120 views
What techniques are useful for modelling Character Actions via OOP? [duplicate]
I'm trying to rewrite a legacy php Browser-Based-Game so that it uses object oriented programming. I find it relatively easy to model concrete nouns, like: new Npc(), new Character(), new Account(), ...
0
votes
1answer
30 views
sfml/opengl, two objects of same class are sharing variables
whenever I use the none-default constructor, it only adds to the coordinates of the previous class(in an array)
wall_1x1 wall[2] = {
wall_1x1(0, -2, 0), //first argument is x, second z, and ...
0
votes
0answers
67 views
Using an object as a model to avoid too many parameters - XNA/C#
I have 3 classes(Skill,Projectile and Status),Skill has Projectile and Projectile has Status, all of them need to read information from a txt and to avoid open it everytime I want to create an object ...
0
votes
2answers
88 views
Can we create same name class for different objects in unity?
I have four similar objects in my game. As they are all similar therefore I have created a single script that defines mash for all of them. The script that defines mash for these objects uses a ...
0
votes
2answers
276 views
Good design for skills (heal,dmg etc)
I'm trying to create a good designed "skill system" for my game, but curious if anybody knows a good design?
Skills can Heal,Damage ofc, they can be single target,multiple(chain), AOE.
Instant dmg/...
2
votes
1answer
123 views
Good approach in designing game classes [closed]
I took a semester-long course in java but I'm still a beginner in Object-Oriented programming paradigm. Suppose that I want to create a simple game where the player can go to different locations. Each ...
5
votes
2answers
412 views
How should entities in a game reference each other?
I've been reading a lot about design patterns, but in using these patterns there's one question that I keep coming back to. How should my entities access information about each other?
Let's say I'm ...
0
votes
1answer
99 views
Is it better to make a cpp and hpp file for every new object or is it better to make one parent class and define types in there? [closed]
Let's say we make a game. The game has items, enemies, allies, etc and there are multiple of them, like zombies and robots as enemies. Do you think it would be better to make one parent class called "...
0
votes
1answer
131 views
Passing of board data in board games
Every time I make board game, I am faced with a decision. I have classes for the board and/or game logic, and another for the UI. I don't know how I should pass the board data to the UI. I could make ...
1
vote
4answers
449 views
Class design and data structures for a Tower Defense
I was trying to come up with a structure for a simple TD game that has following elements
Tower
Each Tower has a set of properties like range, damage, health etc
There could be different types of ...
3
votes
1answer
412 views
How should my game characters store their abilities/spells?
I'm new to game development and a bit confused about how to effectively store an object's access to certain spells/abilities.
The player and mob objects are all generated from the same class. However,...
2
votes
1answer
130 views
Design pattern for level editor modes?
In a level editor that supports multiple editing modes, written in an oop language, how would you go about switching from mode to mode, considering that data itself remains the same?
I am using a MVC ...
1
vote
1answer
278 views
OOP design, keeping track of entities
First, I would like to say that I have no experience with this and am still getting my head around OOP, so if something is really obvious, just point it out :)
I am designing a game and I am not sure ...
3
votes
1answer
885 views
Architecture to draw many different objects in OpenGL
I have some objects that I want to draw. I am not sure how I can create my architecture in a way where I can draw everything as fast as possible.
As example:
class MyObject
{
float[] vertices;
...
1
vote
2answers
162 views
Command Interface design for RTS
Commands may have different target type; like NONE, COORD, UNIT.
Some example commands may be: Attack (target UNIT), Move (target COORD), AttackMove (target COORD), Stop (target NONE), UseAbility (...
1
vote
2answers
155 views
OOP Question for Team System
I'm not quite sure right how I should create my "Team System".
Lets say I have 2 teams with 4 players in there. The teams are Team Blue and Team Red.
A team knows the amount of its members, the amount ...
1
vote
1answer
245 views
Game development for high-school with C++ and OpenGL [closed]
I've been teaching high-school students (12th grade) game programming in the last 2 years. The way I did this till now, was first to give them "half made" classes (for Point, Polygon, etc.) and they'...
0
votes
2answers
39 views
GameLogic Model as Property or Constants with lookup in other Models?
Basically imagine a game where the Player has a Weapon which has a BulletType/type of Bullet.
Now Player, Weapon and Bullet are Models having properties and they would represent Instances in the game....
2
votes
2answers
290 views
Decoupling the entity from whatever controls it
In a lot of games the player can choose whether an entity will be controlled by the AI or by the player. For example in the game Little Fighter 2, the player can choose how many of a maximum of 8 ...
1
vote
2answers
153 views
Is it acceptable to mix simple physics logic with gameplay logic?
In my 2D game I have a PhysicsEngine class. It currently does two things:
Called every frame to apply global forces on all entities (e.g. gravity).
Called by the CollisionDetector to do the physics ...
4
votes
0answers
573 views
Why are god objects so common in game programming? [closed]
This is a bit of a philosophical question. Excuse me if it's out of place here.
Most modern games developed in C++ use (or at least purport to use) an object-oriented approach. A common axiom of ...
0
votes
1answer
72 views
How to modify Game1.cs out of an object it contains? [closed]
Assuming I Have a List<SomeClass> myList; in my Game1-class. It also contains an object of SomeOtherClass otherClass;. How would I modify myList (Add/Remove) out of the otherClass's logic? Or in ...
3
votes
2answers
176 views
Should entities store other other entities that they spawned?
How should a game entity add another game entity to the game world?
For example, an entity shooting a missile (which is another entity), means the new Missile will need to be added to the entities ...
5
votes
3answers
683 views
How to handle collisions without ugly conditionals and type checking?
(I asked a similar question, but this one is far more specific).
How can I handle collisions without having to do a lot of type checking and if statements?
People here suggested that when spotting a ...
-1
votes
2answers
181 views
How to avoid tons of `instanceof` in collision detection? [duplicate]
Consider a simple game with 4 kinds of entities: Robots, Dogs, Missiles, Walls.
Here's a simple collision-detection mechanism in psuedocode: (I know, O(n^2). Irrelevant for this question).
for(...
1
vote
2answers
344 views
Updating entities in response to collisions - should this be in the collision-detection class or in the entity-updater class?
In a game I'm working on, there's a class responsible for collision detection. It's method detectCollisions(List<Entity> entities) is called from the main gameloop.
The code to update the ...
1
vote
1answer
57 views
How should I handle a modelview stack with multiple shader programs involved?
I'm building a framework where each object has an associated program and each object has a 'draw' method.
What is the best choice, to have a single modelview stack handled by a Renderer class or to ...
0
votes
1answer
116 views
How to store and use different AI behaviours
I'm coding a space shooter on three.js (WebGL) and since the game I'm doing is rather simple, plus I want to keep controll of the structure, I'm not using a game engine.
I'm using oop classes and ...
1
vote
0answers
434 views
Big game in Flash - how to create levels structure
I'm building a game in Flash similar to the structure of Angry Birds or Cut the Rope (where there are a number of "rooms" and unique levels created within each "room").
The user gets through the game ...
0
votes
0answers
23 views
Component systems: No inheritance hierarchy at all, or a basic one? [duplicate]
(I asked a similar question, but it had more questions inside it and I feel it wasn't clear enough, so I'm opening a new one).
Until recently I implemented all my games using an inheritance hierarchy....
9
votes
3answers
409 views
How do AI agents access information about their environment?
This might be kind of a trivial question, but I am having trouble understanding this. Would very much appreciate your help.
In game development using object oriented design, I want to understand how ...
2
votes
2answers
120 views
What is the advantage of wrapping D3D in a class versus a namespace?
Almost all the tutorials and books use a class wrapper for Direct3D. But I haven't found any scenario in which using more than one instance of Direct3D system (the "device" and state, et cetera) is ...
14
votes
6answers
2k views
OOP architecture for Hero with many attributes
I'm about to start a simple browser text RPG, with characters that can (passively) fight other people. This involves a list of about 10 skills like strength, dexterity and so on, with additional ...
0
votes
1answer
98 views
QuadTree treeNode design question
I'm a programming newbie.
I have a Quadtree. I created a TreeNode class that the Quadtree will use as nodes. I have spriteNode that inherits from TreeNode.
However, I also have several sprite ...
5
votes
4answers
3k views
How to make a game without OOP? [closed]
I am currenty studying game development and practicing making games.
I use a lot of OOP in my games. For example, each missile that is shot is an instance of a Missile object, and added to a list of ...
0
votes
3answers
87 views
Getting entity type object [closed]
I have a custom entity class and what it does is create a SQUARE object.
public class Entity {
Rectangle rect;
public Entity() {
this.rect = new Rectangle(20,20);
rect.relocate(200,200);
...
0
votes
1answer
943 views
Superclassing RPG Game Entities [closed]
I am in the design process of an RPG game and I have no experience at all in game dev.
This question is about how I should approach entity management using OOP classes.
My train of thought is as ...
1
vote
2answers
3k views
C++ OOP Implementation of a game [closed]
I've been recently trying to get into Object Oriented Programming by porting a game I've made in C to C++. The problem is, even though my implementation works, I don't know if is the best approach.
...
1
vote
1answer
1k views
Best Practices for class usage and game architecture
I'm making a 2D game similar to mario in Java.
I have some questions about class organization and proper method usage.
I have the following classes:
Main: runs the game in a JFrame
GamePanel: ...
2
votes
1answer
633 views
Multiplayer in a game. How to design it object wise?
I was suggested on StackOverflow to ask this question here.
I'm working on a simple game and I was thinking of adding multiplayer feature but I'm a bit stuck. I'm not sure what approach should I take,...