Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Jun 2001
Online Last Active Today, 05:23 PM

#5257127 Class / array question

Posted by Madhed on Today, 05:06 PM



You are trying to initialize a vector of VertexPos with a list of XMFLOAT3's which is not going to work.


So either you need to make it std::vector<XMFLOAT3> or put another pair of parentheses around the initializer elements like so:

mObject->vertices =
	{XMFLOAT3(0,0,0)}, {XMFLOAT3(0,0,0)}, {XMFLOAT3(0,0,0)}

#5257121 Class / array question

Posted by Madhed on Today, 04:50 PM

Weird, I just tried with VS.net 2015 community edition and it works. Can you post the code of the VertexPos class and the way you initialize the list?

#5257115 Class / array question

Posted by Madhed on Today, 04:20 PM

you can use a std::vector.


If your compiler supports c++11 you can even use the array initializer syntax like in your example.

#include <vector>

class Object

	std::vector<VertexPos> vertices;

mObject->vertices = { ... }

#5256878 Variable size strucs

Posted by Madhed on Yesterday, 10:33 AM

Yes indeed. But then, how do you define the "material" object ? This material object will need to have thoses fields anyway with the arrays


Well, the main idea is that not every draw item will have a unique combination of shaders and textures, etc. By moving the shared data into a material you will save memory in your main draw queue, it's basically the flyweight pattern.


Also you will want to sort your render queue by some criteria which will probably include a material id. Since the number of materials will hopefully be much less than the actual number of draw calls you could use some "heavier" data structures like vectors for the varying length parameters like textures and constants.

#5254146 MySQL statement error

Posted by Madhed on 26 September 2015 - 09:37 AM

No. NULL is very different from 0. NULL basically means the value of this field is not known, whereas 0 is a known numerical value.

#5254124 Intersect ray with heightmap

Posted by Madhed on 26 September 2015 - 06:36 AM

You can  use the Bresenham algorithm to check which cells to test.



#5251613 Sort unit vectors clockwise

Posted by Madhed on 10 September 2015 - 03:44 PM

1. Store them in 4 buckets for each quadrant by comparing the x and y sign.

2. calculate each tangent y/x

3. sort by tangent using your favorite sorting algorithm

4. combine quadrant buckets in clockwise order

#5247837 Structure of object-to-object interaction? (And other questions!)

Posted by Madhed on 20 August 2015 - 05:24 AM

I think these types of mutual interations are better handled through a mediator.

Creature::attack() {
    world.attack(this, enemy, AttackType::MELEE_ATTACK);

World::attack(Creature attacker, Creature enemy, AttackType type) {
    attackHandler = attackHandlers.get(attacker, enemy, type);
    if (attackHandler) {
    else {
        // No AttackHandler found for interation between attacker and enemy

MeleeAttackHandler::doAttack() {
    if (attacker.att > enemy.def) {
        enemy.applyDamage(max(0, attack.damage - enemy.shield));

    if (badluck() > 0.1 && enemy.def > 8) {
        attacker.applyDamage(10); // hurt your hand while punching enemy


This prevents your creatures from directly altering the state of the other creatures and allows you to add specialized attack handlers later on if you want to expand.
A similar system could also be used for other interactions between two or more entities, for example reacting to sounds made by a creature.

#5242743 Breaking out of a nested loop

Posted by Madhed on 26 July 2015 - 06:22 AM

Look ma! no breaks!

int i, j;

for(i = 0; i < 2; i++) {
    for(j = 0; j < 10; j++) {
        // if(i - 1 == j + 1) <- will be true for i==2 and j==0

seriously though, how often will you have a situation where you need a nested loop and break out on an arbitrary condition and continue work after the loop?


Smells to me like a violation of SRP.


Some possible solutions depending on the actual algorithm:


Factor out the loop into another function and just return instead of breaking

or calculate the terminating condition beforehand and adjust the loop boundaries

or collect the affected elements and iterate over all of them



#5241383 [Javascript] Securing properties from client-side tampering

Posted by Madhed on 19 July 2015 - 10:50 AM

Never trust a client. The server must be the single authoritative entity at all times. You can think about insanely complex measures to prevent client side cheating but in the end hackers will always find a way around that,


So basically what you are writing in your last paragraph is how it should be done. The client only sends its intention to do something to the server which in turn changes the game state after checking the validity of the player's requests.


In order to get around the problem of latency (player presses key but only starts to move after the server has sent a response) you can employ client side prediction techniques to mask the delay. Since you are building an RPG you can also think about game design changes that mask the delay. e.g: Show "progress bars" before executing a spell so the player just thinks the delay is actually part of the game. ;)

#5241347 Good C++ engines?

Posted by Madhed on 19 July 2015 - 05:11 AM

There's always the chance that an upate may cause problems. But IMHO you are exposing your system to more harm by not installing SP1 which came out in 2011(!)

#5241343 Good C++ engines?

Posted by Madhed on 19 July 2015 - 04:46 AM

I have Windows 7 Ultimate, how can I get that SP1 for windows 7 ?


Windows update

#5238657 What kind of games can I create with my 3 member team that someone may actual...

Posted by Madhed on 06 July 2015 - 02:20 PM

Realistically, your first game is most likely not going to be a (huge) success.

That's why it is important to not sink too many man-hours into this first project.


Your best bet would be to come up with a simple game, focussed on a single gameplay mechanic and polish that until it is ready for relasing.


Since you dont have artists on your team but still want to use advanced gfx features you should aim for the "abstract" art style.

Use basic geometric shapes but apply shaders that make them look interesting.


Prototype first, this lets you quickly see if your idea is fun to play at all. Do not spend too much time working on the details in the beginning!


Let your friends/family test the game, they might give you important feedback.


The most important thing really is to just start. Unity is such an amazing engine for quick prototyping that you can quickly hack something together and test your ideas.


Good luck!

#5238565 What kind of games can I create with my 3 member team that someone may actual...

Posted by Madhed on 06 July 2015 - 02:02 AM

I'm just a bit scared of devoting hundreds of hours to a game that no one will play


Solution: Don't devote hundreds of hours into a game that no one will play. Shrink the scope and devote tens of hours into a game that no one will play and learn from the mistakes for your next game.

#5235900 Code crashing when exiting if statement

Posted by Madhed on 20 June 2015 - 01:24 PM

Could be a crash inside the log function?


Anyway, did you run it with a debugger? Assuming visual studio, hit F5. It will build your program in debug mode and attach a debugger. When the program crashes you can pinpoint the exact location and look at the state of the variables to see what is going on.