Jump to content

  • Log In with Google      Sign In   
  • Create Account

mark ds

Member Since 07 Jan 2010
Offline Last Active Yesterday, 04:25 PM

#5206391 c++ how to detect Enter button input

Posted by mark ds on 24 January 2015 - 09:50 AM

Which operating system are you using, and which programming language?

#5204019 Code appearance, is it really important?

Posted by mark ds on 13 January 2015 - 02:27 PM

It's not just the appearance of the code that matters: the second example shows a clarity of thought when tackling the problem domain, the first feels more like a mental hit and miss approach (i.e. you started coding before you knew what you wanted to code).


It happens to everyone - sometimes you just can't see a clean solution to a problem. I often find just walking away from the computer for a few moments can help, or in more complex cases getting out a pen and paper and writing down what you want to achieve, be it in English or via a flow chart or similar.

#5199040 Easiest coding language?

Posted by mark ds on 18 December 2014 - 07:31 PM

To Serapth


From Lua's Wiki: Lua is crap!


"Lua is a tiny and simple language, partly because it does not try to do what C is already good for, such as sheer performance, low-level operations, or interface with third-party software. Lua relies on C for those tasks. What Lua does offer is what C is not good for: a good distance from the hardware, dynamic structures, no redundancies, ease of testing and debugging. For that, Lua has a safe environment, automatic memory management, and great facility to handle strings and other kinds of data with dynamic size."


In  this modern age, battery life is just as important as absolute performance.

#5198350 Easiest coding language?

Posted by mark ds on 15 December 2014 - 10:42 AM

If you're starting from scratch, I'd have to seriously recommend downloading Visual Studio 2013 Community Edition, and learning C#. There are loads of online resources, but better still buy a good C# book.


After several months of hard graft getting your head around programming, look into using an existing game engine, such as Unity or Unreal (both of which can be used with C#).

#5197757 Scaling sprites with distance?

Posted by mark ds on 12 December 2014 - 06:48 AM

If you double the distance you halve the size.

#5196878 C++: Easiest way to implement an in-game Time/Date system?...

Posted by mark ds on 07 December 2014 - 06:40 PM

Don't use GetTickCount, use QueryPerformanceCounter along with QueryPerformanceFrequency.

#5195426 laptop for programming

Posted by mark ds on 29 November 2014 - 08:14 PM

How are you finding your Surface Pro? I'm very seriously thinking of getting one. (or maybe the Pro 4)

#5195093 laptop for programming

Posted by mark ds on 27 November 2014 - 08:58 PM

Don't forget that you can run  Windows on Mac...

#5195080 laptop for programming

Posted by mark ds on 27 November 2014 - 06:26 PM

What's your budget?


This being a game programming site would suggest you're looking at graphics capabilities. However, cheap laptops have crappy GPUs. If you're talking about general programming, I'd suggest a large 1920x1080 screen. Having more on screen really does help. Apart from that, *any* laptop can be used to programme.

#5195062 how to create gui buttons with DirectX 11?

Posted by mark ds on 27 November 2014 - 04:55 PM

A button is usually nothing more than a virtual rectangle that exists within the client area of a window. As the user moves the mouse just test whether the mouse is inside of each rectangle (perhaps using PtInRect). Now this doesn't help the user much, so you would also have to render some quads on the screen in the same positions using some kind of button texture - perhaps a 'normal' one and a 'mouse over' one. Something like



Attached Thumbnails

  • example.jpg

#5193735 Need a short name to replace a really really long function's name

Posted by mark ds on 20 November 2014 - 01:22 AM




You function name isn't even that long compared with the gl function above. However, the point of function names is to be descriptive, irrespective of how long they are. If you come back to this code in 5 years will you be able to tell exactly what the function does without any comments? If not, rename it to something more meaningful.

#5193454 Text dissapearing when resizing or minimizing window.

Posted by mark ds on 18 November 2014 - 10:27 AM

Also, there should be a "break;" at the end of WM_PAINT, because at the moment the code falls straight into WM_SETFOCUS. It's a pretty shoddy code example from MSDN, to be honest.

#5193452 Text dissapearing when resizing or minimizing window.

Posted by mark ds on 18 November 2014 - 10:20 AM

In WM_SIZE the code



if (pTextMatrix != NULL) free(pTextMatrix); // If there is enough memory, allocate space for the  // text input buffer.
pTextMatrix = (char*)malloc(nWindowCharsX * nWindowCharsY); 


deletes all of the text you have entered, and then recreates pTextMatrix based on the number of characters you can fit in the client window. You need to move the allocation/de-allocation somewhere else (possibly allocate in WM_CREATE and de-allocate in WM_DESTROY).

#5192741 Optimization in C#, code too slow and help with translation

Posted by mark ds on 13 November 2014 - 05:12 PM

Your memory access pattern is the problem.


In your code you're doing:


for(x = ....

    for(y = ....


which is always a bad idea. Change it to:


for( y = ....

    for( x = ....


This maximises cache usage because of the way the bitmap is stored in memory.

#5192733 Corrupting of the view if far from world center

Posted by mark ds on 13 November 2014 - 04:17 PM

Never move the camera around the world - move the world around the camera. For example, if you are walking north along a terrain, you'd actually move the terrain south. This gives you maximum floating point precision where you need it - up close.