Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Khatharr

Member Since 24 Apr 2010
Offline Last Active Today, 09:27 AM

#5190697 Correct analogy about ordinals and combinatronics?

Posted by Khatharr on 02 November 2014 - 03:22 AM

The analogy fails because the relationships are not congruent.

 

Permutations do indeed relate to ordinals, since they refer to position within an ordered set. Combinations may relate to cardinals, but cardinals would apply in the same way to permutations.

 

A permutation is a set/collection where order is relevant. A combination is a set/collection where order is not relevant.

A cardinal refers to a quantity, such as 'three apples'. An ordinal refers to position, such as 'the second apple'.




#5178218 Storing Objects With The Same Base Class In Vector

Posted by Khatharr on 04 September 2014 - 10:23 PM

 The code seems pretty fishy to me, but at the very least replace this:

 

std::vector<std::vector<GUI_Model*>> pages

 

With:

 

std::vector<std::vector<std::unique_ptr<GUI_Model>>> pages

 

If you want to store these types by value in the container, and you have a known # of them, you can use boost:variant.

 

 

 

My bad, man. I didn't mean to downvote that. There doesn't seem to be a way to undo it.




#5174061 pointer value

Posted by Khatharr on 16 August 2014 - 03:24 AM

float * pin28Value; //create a pointer to some address

*pin28Value = 0.5; //write 0.5 to the location in memory that the pointer is pointing to

XPLMSetDatavf(pnlBri, pin28Value, 10, 1); //russian roulette




#5173960 Sorting out the bits

Posted by Khatharr on 15 August 2014 - 12:57 PM

// 4 bits: material group
UINT64 makeKey = tr.MatGroup;
// 8 bits: materal ID
makeKey <<= 8; //push it over by 8 bits to make room
makeKey |= tr.Material & 0xFF;
// 8 bits: mesh ID
makeKey <<= 8; //push it over by 8 bits to make room
makeKey |= tr.Mesh & 0xFF;
// 16 bits: mesh inst ID
makeKey <<= 16; //push it over by 16 bits to make room
makeKey |= tr.Instance & 0xFFFF;
// 8 bits: dist to cam
makeKey <<= 8; //push it over by 8 bits to make room
makeKey |= (char)tr.DistToCamConv; //float is usually 32bit, so casting to char will give you an 8-bit value...



#5173882 Sorting out the bits

Posted by Khatharr on 15 August 2014 - 08:08 AM

You forgot to include testbucket.txt. (I recreated it from what you posted in the chat.)

    UINT64 makeKey = 0;
    makeKey |= (UINT64)tr.MatGroup << 40;
    makeKey |= (UINT64)tr.Material << 32;
    makeKey |= (UINT64)tr.Mesh     << 24;
    makeKey |= (UINT64)tr.Instance << 8;
    makeKey |= tr.DistToCamConv; //this one's a float, I guess

You were shifting int's and then or'ing them into the UINT64. The information was being lost before it was added.

 

Another way to do it is to just or in a value, then use <<= on makeKey to make room for the next value.




#5169656 Getting started from almost complete scratch.

Posted by Khatharr on 27 July 2014 - 09:11 PM

http://www.gamedev.net/topic/651842-please-read-the-faqs-before-you-post-for-the-first-time/




#5168116 Thinking in Javascript

Posted by Khatharr on 21 July 2014 - 04:43 AM

I think you'll be fine with the book you're reading and maybe a handy reference. JS is pretty straightforward once you understand the idea behind HTML, CSS, and DOM in general.

 

"To fully understand the beauty of LEGOs you need to think in LEGOs, many people build with art/science/efficiency in LEGOs and that doesn't cut it"




#5167752 New Earth RPG

Posted by Khatharr on 19 July 2014 - 02:18 AM

Thank you for telling us that.




#5165753 how to use or ||

Posted by Khatharr on 09 July 2014 - 02:06 AM

It should be noted that performing your comparisons using multiple Boolean variables means that you cannot take advantage of short-circuit evaluation.

 

VS2012, compiled with default release mode settings:

#include <random>
#include <chrono>
#include <iostream>

int main() {
  std::srand(time(NULL));
  int val = rand(); //prevent compiler from just generating the result at compile time

  bool a = val < 10;
  bool b = val > 100;
  bool c = val > 50;
  bool d = val < 60;
  bool result = a || b || (c && d);

  std::cout << result << std::endl; //prevent compiler from skipping process due to unused result
  return 0;
}

Resulting disassembly:

#include <random>
#include <chrono>
#include <iostream>

int main() {
002F1270  push        ebp  
002F1271  mov         ebp,esp  
002F1273  push        ecx  
  std::srand(time(NULL));
002F1274  push        0  
  std::srand(time(NULL));
002F1276  call        dword ptr ds:[2F30BCh]  
002F127C  push        eax  
002F127D  call        dword ptr ds:[2F30C8h]  
002F1283  add         esp,8  
  int val = rand();
002F1286  call        dword ptr ds:[2F30CCh]  
  bool a = val < 10;
002F128C  lea         ecx,[eax-0Ah]  
002F128F  cmp         ecx,5Ah  

  bool result = a || b || (c && d);
002F1292  ja          main+34h (02F12A4h)  
  bool b = val > 100;
  bool c = val > 50;
002F1294  cmp         eax,32h  

  bool result = a || b || (c && d);
002F1297  jle         main+2Eh (02F129Eh)  
  bool d = val < 60;
002F1299  cmp         eax,3Ch  

  bool result = a || b || (c && d);
002F129C  jl          main+34h (02F12A4h)  
002F129E  mov         byte ptr [result],0  
002F12A2  jmp         main+38h (02F12A8h)  
002F12A4  mov         byte ptr [result],1  

  std::cout << result << std::endl;
002F12A8  push        dword ptr ds:[2F3024h]  
002F12AE  mov         ecx,dword ptr ds:[2F303Ch]  
002F12B4  push        dword ptr [result]  
002F12B7  call        dword ptr ds:[2F302Ch]  
002F12BD  mov         ecx,eax  
002F12BF  call        dword ptr ds:[2F3028h]  

  return 0;
002F12C5  xor         eax,eax  
}
002F12C7  mov         esp,ebp  
002F12C9  pop         ebp  
002F12CA  ret  

Compilers are very, very smart.




#5165750 Need advice with RPG making

Posted by Khatharr on 09 July 2014 - 01:41 AM

Dark Basic and its derivatives are overwhelmingly deprecated. SDL or SFML would be better alternatives at this point in time.

 

RPG Maker uses only an extended form of Ruby (called RGSS), but allows you to rewrite all but the most fundamental aspects of the engine. If you want to learn the fundamentals of programming, RPG Maker is not a bad place to start. You can start making games without any programming knowledge, and then start studying Ruby and immediately applying what you learn to tweak the functionality of those games. Additionally, the default set of scripts that power the engine will show you some good ideas for game program architecture and how to do things like tile based collision, etc. It's a tool that you can use until you outgrow it, at which point you should have a good understanding of Ruby and OOP, which can potentially ease the initial learning curve for more commonly used languages like C++, C#, or Java.

 

To be clear, RPG Maker can't do everything, but it can certainly do an awful lot, and the documentation that comes with it is a very good starting point for beginning programmers. Ruby is not a widely used language, but it is a quite capable language. I haven't used RPG Maker for several years now, but I still use Ruby on a near daily basis for things like local automation and socket testing under Windows (and sometimes Linux), even though I primarily code in C++.




#5163395 decompositing and recompositing color (pixel)

Posted by Khatharr on 28 June 2014 - 02:49 AM

Not really an optimization, but I'd like to throw a little fuel on the fire...

union uColor {
  struct {unsigned char blue, green, red, alpha;};
  unsigned int uint;
  unsigned char channels[4];
};

More importantly, take my advice and use a profiler on your code before you try to optimize it.




#5160927 Bell's theorem: simulating spooky action at distance of Quantum Mechanics

Posted by Khatharr on 16 June 2014 - 03:55 PM

You need to publish a paper on this.




#5160344 Refactoring if-conditions for player turn code

Posted by Khatharr on 13 June 2014 - 12:30 PM

~snip~

 

To be honest, when I see long nested if-trees I mentally replace the whole thing with a picture of spongebob jumping up and down. I get why it's not great to do it all on one line around JPs, but something like:

int result = 0;
if(vDir.x < vDir.y)  {result += 0x01;}
if(vDir.x > -vDir.y) {result += 0x02;}
return result;

Is much preferred for me. It's actually a lot more to do with visual efficiency rather than performance efficiency. I can look at those three lines and sort out what's going on in a few moments, but I'm simply not interested in browsing through that whole if-tree to see what details are where.

 

This is kind of a poor example of what I mean, since this really is the simplest use case for this and it could easily go either way, but when you get to something where you're crapping out ordinals based on 14 different conditions, it can be a lot easier to sort out a one-page bit-field rather than a five page if-tree.




#5156495 More fun with std::regex

Posted by Khatharr on 28 May 2014 - 09:24 AM

Never mind. I found the problem. Apparently regex_search() only grabs one match and any submatched groups. You have to re-search the suffix string to get more matches. -.-




#5139900 c# game

Posted by Khatharr on 17 March 2014 - 11:09 PM

well spiro you SUCK I hate this board, I am going to go else where for answers , go ahead and bann me I give up!!!!!!!!!!!!!!

 

Farewell, phil67rpg. We hardly knew ye... (Spiro doesn't suck.)






PARTNERS