Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 09 Jan 2001
Offline Last Active Today, 02:56 AM

#5243042 Breaking out of a nested loop

Posted by MarkS on 27 July 2015 - 01:35 PM

If you want to see a real masterpiece, look at page 3 or 4 of the comments here https://derpibooru.org/883523

What the...blink.png That's a real site? 

#5242919 why do we need to divide w in texture projection

Posted by MarkS on 27 July 2015 - 02:30 AM

Dividing by 'w' gives perspective correct texture mapping. Failing to do so will give affine texture mapping, which has issues with distortion and texture crawl.


Image from:

#5242869 Breaking out of a nested loop

Posted by MarkS on 26 July 2015 - 06:17 PM

Anyone else who is going to stop using nested loops at all?

I'll use a goto statement and face the wrath of the dreaded velociraptor (see here) than write that mess!

#5242855 Breaking out of a nested loop

Posted by MarkS on 26 July 2015 - 04:34 PM

for(int i=0,n=0; n<10; n += ((i+1)==10), i+=((i+1)==10)*-9+((i+1)!=10)){

look ma, no division or additional branching tongue.png

This is turning into a Coding Horrors post!

#5242824 Who wants to see a C replacement?

Posted by MarkS on 26 July 2015 - 02:39 PM

So I take it you guys are not building platforms here? Let me give you some background on where I am coming from with the headers. I am what we call a platform developer on my team. Essentially what I do is define the interface in header files that gets exposed as an API set to the end user. The end user is another group on my team. As someone in this position, I can tell you that having to deal with header files is a huge mess. If you are a one off developer, I can see it not being so much of an issue. However, when you are the one who has to maintain those header files across versions and the platform, it becomes ugly. Not only do I have to worry about our libraries getting distributed, but I need to make sure everyone has the correct header files. If I make one small change in a header, that becomes a nice change in terms of the interface and possibly a big documentation artifact. Since our code base is getting ever bigger, we run into the situation where I forget to distribute some new headers I changed or somebody forgot to update them. This causes issues when people are trying to run their code. Sometimes it won't compile, or sometimes I just changed a structure definition and the code fails. It wouldn't be caught in compilation for this last point.

The headers should only expose the implementation in this case. If you are changing the headers to a library, you are breaking any code base using that library. Why would you need to change the header, unless your library is not finalized, and then, why does it matter?

Without headers, how do you expect to expose the library to the calling code base? Will I have to write my own copy of the necessary structures, variables and function pointers?

#5242801 Who wants to see a C replacement?

Posted by MarkS on 26 July 2015 - 01:17 PM

I do not see a reason to "replace" C. C is still a very valid and useful language and is still used in OS design and embedded systems. It is hard to find another high-level language that allows you to get close to the bare metal. If I wanted to see anything changed in C it would be to replace malloc/calloc/free with new/delete. Here's the thing though... I can write pure C code in any modern C++ compiler, and if I so choose, can freely mix in various C++ features. I DON'T have to use malloc/calloc/free!

#5242684 Creating file reader/level loader C++

Posted by MarkS on 25 July 2015 - 04:04 PM

This is why I prefer binary files over human-readable. You read in the header, extract the data offsets and then either read in the data, offset by offset, directly into your data structures or read the entire data block from the file into a buffer and parse it there. Sure, you lose the readability of a human-readable format, but your editor should make that unnecessary anyway.

#5241565 Good C++ engines?

Posted by MarkS on 20 July 2015 - 12:19 PM

Yeah, turn on Windows Update! I just installed VS Community on my Windows 7 Home Premium 64-bit machine without problem, but I keep it up to date. You are putting yourself in quite a bit of danger by not having Windows up to date. There have been MANY security updates that you have missed since install.

#5240899 Displacing mesh data based on displacement map

Posted by MarkS on 16 July 2015 - 02:30 PM

For simplicity, let's assume that your displacement map is 64x64 texels and 8-bits per texel. To map this perfectly to a quad, the quad would need 64x64 vertices, with each vertex in the quad corresponding to a texel. Each texel ranges from 0 to 255 and you need both positive and negative values to accurately displace the vertices, so divide by 256 and subtract 1, scaling the value to between 1 and -1. You then multiply this scaling factor by a user-definable offset and translate the corresponding vertex by this amount.


So, for a texel value of 64:


64 / 256 = 0.25

scaling value  = 0.25 - 1 = -0.75

-0.75 is 3/4 the unit length, so too large of a scaling factor, so multiply by an arbitrary offset, say, 0.1:

-0.75 * 0.1 = -0.075

Assuming the quad's vertices are along the x-y plane, offset the corresponding vertex's z coordinate by -0.075. Do this for each texel/vertex. Fewer vertices means lower resolution, but this is OK if you're doing LOD. This procedure gets a lot more complicated if you are displacing non-planar objects.

#5239651 What game engine should I use?

Posted by MarkS on 10 July 2015 - 06:53 PM

I would try out Godot engine for a game like this. It looks very promising.

I agree here. It has some incredibly powerful 2D tools.

#5239617 How can i save player data, and how to prevent cheating?

Posted by MarkS on 10 July 2015 - 03:14 PM

For me is, why would you do any kind of cheat prevention for a single player game? If I want to "cheat" myself, why make it harder for me? Maybe some parts of the game are too hard and I am not willing to spend some hours of getting better at that part. IOW, I am not competing with anybody else and I play games for my own enjoyment and not somebody else.


When I play Morrowind, Oblivion, or Skyrim, I turn on God Mode and use the console to force all of my stats up high as well as load my character up with gold and other necessary items. Why? Because I do not like playing the same dungeon over and over and over simply because my character is a level 1 or 10 or whatever. I want to play through. This is how I like to play. If it isn't how YOU like to play, fine, don't, but let me enjoy the game.

#5239599 How can i save player data, and how to prevent cheating?

Posted by MarkS on 10 July 2015 - 02:29 PM

All three of those options can be fairly easily circumvented by disassembling the code and seeing what it does.  And it only takes one smart person to do it and automate the process so that everyone else can cheat as well.

Which is why I suggested simple obfuscation (i.e., binary files and such). You will only stop the inexperienced hackers. Wasting time trying to stop the experienced hackers is just, well, a waste of time. If I want to hack your game, I will, and I have the tools at my disposal to do so. Nothing you are going to do will stop me from hacking your game; all you'll do is slow me down. How much you slow me down depends on my skill level.

#5238399 Is this Possible? What should I use? [Newbie]

Posted by MarkS on 04 July 2015 - 09:02 PM

Everything you've said is totally possible.

To be quite honest, this shows a lack of understanding of game design and programming. I'm not trying to be rude, but this is really very simple and basic stuff. The hardest part will be the graphics. Do you have the technical knowledge to pull this off? That is the real question.

#5238012 Applying alpha gradient to an image

Posted by MarkS on 02 July 2015 - 09:56 AM

Use an image editor that lets you save your image with an alpha channel.

He's generating the image dynamically, but your point is still valid. Generate the alpha channel while generating the image.

#5238005 How can i save player data, and how to prevent cheating?

Posted by MarkS on 02 July 2015 - 09:42 AM

i think i should stop thinking about about cheaters and hackers then sad.png

No, but you shouldn't put too much thought into it. Some sort of simple obfuscation to keep people from using a simple editor would suffice, but give up the idea that you will ever prevent hacking/cheating. You can spend months on this alone and still fail.

Focus on the game.