Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Apr 2010
Offline Last Active Private

#5273300 Random Generation Issues

Posted by Khatharr on 29 January 2016 - 08:33 PM

The Generate() function appears to be malformed.


Put a breakpoint at the start of it and walk through it with the debugger and look at what it does. If this behavior is intentional then you certainly don't need a loop. I'd also recommend making the randomizer a static member or else placing it elsewhere and passing it in to the function so that you aren't creating a new randomizer object every time the function is called.

#5273271 Warning conversion from size_t to int in x64

Posted by Khatharr on 29 January 2016 - 03:53 PM

It's not really a matter of "yet". It's just not in keeping with the C++ philosophy.

#5273250 Game Command Console

Posted by Khatharr on 29 January 2016 - 01:51 PM

Send messages. You don't need to tightly couple the console, if that's what you're worried about. Just add some message-handling to your systems and make a dispatcher. With that in place the console can just be tied directly to the dispatcher.

#5273247 Online RPG Game Programming

Posted by Khatharr on 29 January 2016 - 01:40 PM

Just to put this on the table, I know we see far too many "How does I MMO" threads, and I understand the chafe that comes from people thinking that game dev is trivial work, but the salt could really stand to be toned down.

A lot.

Especially in FB threads, though I get that this one was moved.

In this case OP didn't really even transgress. There's a stated goal of MMO, but OP demonstrated awareness that there's hard work involved and made a general request for information. While it's certainly worth noting that this is indeed a long haul, it's not fair to OP if we take out our frustration over the other questions. OP is asking where to start learning, not where the 'make MMO' button is on the keyboard.

Just sayin'.

#5272947 How do I create a simple game (2d isometric, turn based) like Pokemon?

Posted by Khatharr on 27 January 2016 - 11:23 PM

Game Maker is free (until you want to advanced publishing features) and simplistic for 2D games. Pokemon isn't isometric, but tile-based. In either case, GM can do tile based (very easily) and isometric (there's a tutorial, I believe).

#5272777 Rendering issue (tearing?)

Posted by Khatharr on 26 January 2016 - 07:11 PM

Vsync causes the renderer to wait for a signal from the display before swapping buffers so that the buffer swaps are synchronized with the monitor refresh.


If you're interested in a general purpose image host, I recommend puush, which allows you to upload any image via r-click or to take various forms of screen capture and immediately get a link to the hosted image.

#5272206 sdl 1.2 pacman problems

Posted by Khatharr on 21 January 2016 - 09:08 PM

Perhaps instead of using traditional collision consider using a "rail" system and responding to directional input by setting an "intent" direction?


Without having looked at the code I'm guessing that your entity is experiencing a variant of the bullet-through-paper problem, where there's no frame during which he's perfectly aligned with the intersection in order to be able to make his turn.

#5271984 Advice on coding style

Posted by Khatharr on 20 January 2016 - 05:53 AM

Is there a function call to purge / clear an error in the input stream? cin.clear() didn't work.

Yes. It's in the code I showed you earlier. Look at the steps I used to clean up the stream after the comment.

You're clearing the error flags, but not removing the bad data from the stream.

Also, be advised that using 0 at the beginning of a number is the notation for octal. In the case of 00 it doesn't matter because zero is the same in any base, but 010 is 8, not 10, so watch out for that.

#5271967 Pathfinding and Databases

Posted by Khatharr on 20 January 2016 - 02:03 AM


#5271930 Advice on coding style

Posted by Khatharr on 19 January 2016 - 08:31 PM

I'm not sure what you're asking. At first I thought you were running into the stream in issue with spaces, but from what you said it sounds like you're expecting it get several names and then get the grades after that?


But the code you posted tells it to get one name and then enter a grade input loop, then when the grade loop ends it should ask for the next name.


Could you explain what exact behavior you want to happen, and give an example of the input you're providing it?

#5271604 C++ exceptions

Posted by Khatharr on 17 January 2016 - 04:27 PM

"Sprite::Sprite() - Could not open file "chubu.png" for loading." saves me a nice bit of time compared to, "The program was terminated unexpectedly."


Especially since I can ifdef out the try/catch stuff in the debugger and VC will halt the program at the site of the throw while I'm debugging.

#5271603 static variable in function

Posted by Khatharr on 17 January 2016 - 04:14 PM

Bar& Foo() {
00BC70E0  push        ebp  
00BC70E1  mov         ebp,esp  
00BC70E3  sub         esp,0C0h  
00BC70E9  push        ebx  
00BC70EA  push        esi  
00BC70EB  push        edi  
00BC70EC  lea         edi,[ebp-0C0h]  
00BC70F2  mov         ecx,30h  
00BC70F7  mov         eax,0CCCCCCCCh  
00BC70FC  rep stos    dword ptr es:[edi]  
  static Bar bar;
00BC70FE  mov         eax,dword ptr [_tls_index (0C6A708h)]  
00BC7103  mov         ecx,dword ptr fs:[2Ch]  
00BC710A  mov         edx,dword ptr [ecx+eax*4]  
00BC710D  mov         eax,dword ptr ds:[00C6A1E0h]  
00BC7112  cmp         eax,dword ptr [edx+104h]  //if it's already instantiated
00BC7118  jle         Foo+67h (0BC7147h)  //jump to return
00BC711A  push        0C6A1E0h  
00BC711F  call        __Init_thread_header (0BB7B54h)  
00BC7124  add         esp,4  
00BC7127  cmp         dword ptr ds:[0C6A1E0h],0FFFFFFFFh  
00BC712E  jne         Foo+67h (0BC7147h)  
00BC7130  mov         ecx,0C6A1DCh  
00BC7135  call        Bar::Bar (0BB7A91h)  
00BC713A  push        0C6A1E0h  
00BC713F  call        __Init_thread_footer (0BB88D3h)  
00BC7144  add         esp,4  
  return bar;
00BC7147  mov         eax,0C6A1DCh  
00BC714C  pop         edi  
00BC714D  pop         esi  
00BC714E  pop         ebx  
00BC714F  add         esp,0C0h  
00BC7155  cmp         ebp,esp  
00BC7157  call        __RTC_CheckEsp (0BB91BBh)  
00BC715C  mov         esp,ebp  
00BC715E  pop         ebp  
00BC715F  ret  

#5271602 [SFML] My vector array is only drawing one sprite

Posted by Khatharr on 17 January 2016 - 04:04 PM

Rather than using the temporary and pushing it, you can do:

    enemyVector.emplace_back(new Troll);
    enemyVector.back()->setPosition(std::rand() % 600 + 1, std::rand() % 600 + 1);

#5271540 [SFML] My vector array is only drawing one sprite

Posted by Khatharr on 17 January 2016 - 07:44 AM

If you only put one thing in the container then there will only be one thing in the container. (Show the full code body, not just the parts you like.)

#5271533 C++ console game

Posted by Khatharr on 17 January 2016 - 03:39 AM

Please use code tags when posting code. you can do this manually with [ code] [ /code] or use the < > button in the editor.
The immediate issue is that you declare 'slots' with size 2 but use slots[0], slots[1], and slots[2]. If you want three then declare:
int slots[3];
std::endl places a newline character on the stream and also flushes the stream. If you just want a newline then you can use "\n". For example:
cout << "Your bank roll is " << money << "\n\nPlay again?(y/n): ";
Why cin.get() after using cin >> thing ?

srand() should be called only once for the lifetime of the thread (unless you intentionally want to reseed, which is not the case here).

Move the srand() call to the beginning of main().