Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Nov 2006
Offline Last Active Dec 26 2014 01:57 AM

Posts I've Made

In Topic: How can I create an installer for my game?

23 December 2014 - 06:01 AM

You can do that, or you can write your own. It's all resources, registry settings, temp files, running other installers and public Windows API.


If you want to do the installer quickly, use Inno or NSIS. In case you are curious how it works on the inside, or you want to heavily customize the UI, you might have to roll your own.

In Topic: Windows Dialog Background Color

08 December 2014 - 05:21 AM

I don't know about the rest of the code, but the DlgProc in what you posted above seems wrong.





Return value


Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.


You seem to always return FALSE, which doesn't look good to me.

In Topic: General question: how to keep JavaScript organized

24 November 2014 - 02:25 AM

JavaScript is usually bound to HTML documents. Much like in C++ where you #include your headers, in HTML you <script> them. The browser reads the file top-down (again, much like C++).


It is a very bad idea to make the browser download a lot of files, so you usually bundle  and minify your JavaScript.


It is very rare to split your code like in Java where every class gets its own file. When you write a bit more complex code, you usually wrap it inside anonymous function which you immediately execute to avoid naming conflicts. Assigning the result of the function is kind of.. weird. You usually strive to put code together, you would only do that if you wanted to expose something as public API - and this is rare in JavaScript (unless you were writing a library).


If you really wanted the module systems where JS files themselves include other JS, you would use RequireJS. I haven't looked into their code, but the idea is trivial: you dynamically append a <script> into your <head> and wait until the browser downloads and parses the file (much like you would add an <img>). RequireJS is relatively popular, has tools to optimize your JS (understand: minify and bundle), and you are likely to find answers to your questions at StackOverflow, and also has surprisingly good documentation. 


You didn't say what your project is. Is it browser-based (then just include the <script>-s in the appropriate order), or is it embedded (node, chromium)? How you make script files reference each other depends on how JS is hosted. In any case, since everything in JS is an object, the so described "modules" are just functions where you expose public API by adding it to this (e.g. this.killGoblins = function() {..}), or, if you really needed classes, using the prototype syntax (var goblin = function() {}; goblin.prototype = { object literal };). In most cases, you don't really need classes, you use duck typing. In JS, you've got a lot of free functions just because you don't really need classes and objects most of the time.


How I organize my code depends very much on what I'm doing. Is it a web site? Then follow whatever the framework I'm using dictates. Is it a game? If I can do it in a single file, I would. If the code is bigger, then depend on the <script> order in my JS files (usually located in /js or similar). It may sound horrible to you, but I try to do the simples possible thing first. Plus, in JS, you rarely have to have explicit types.


If you want your code to be more organized and be closer to what you are used to from strongly-typed languages, take a look at TypeScript. I has modules, supports including (and then bundling) multiple files, etc.

In Topic: C# .Net Open Source

20 November 2014 - 09:10 AM

I haven't got the time yet to take a look at what's been open-sourced, but the advantage of Mono over .NET is, and has always been, that it can be embedded in your app. No messy installations, just copy-paste a lot of files into your game directory. A lot of people underestimate installers/uninstallers :)


I'm curious what will follow. Making VS free for "non-enterprise users" (in the Connect() videos they said small companies and indie devs are OK) is an awesome move. If they invest in clang for windows apps (mainly for the clang tools), it would be really awesome.

In Topic: Programming a website?

18 November 2014 - 03:42 AM

The classical resource for learning web technologies is w3schools (http://www.w3schools.com/). Start with the html5 and css3 tracks, then do the javascript track, as advised by alexw.


Then, you will need to learn frameworks that will make your life *a lot* easier. A must-know is twitter bootstrap (http://getbootstrap.com/). It basically eliminates the need to write your own css (but you still have to know how it works in order to tweak small things).


For simple sites, that's all you are going to need. If you need a little bit more complicated stuff, get familiar with XMLHttpRequest (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - mozilla's site is another great resource for web-related technologies) - this is the backbone of the modern web (in tandem with responsive design, which bootstrap will mostly handle for you). Then you may want to get familiar with jQuery/jQueryUI - do not learn it, just browse the demoes to know what is possible. The popular kid on the block these days for javascript is called anglular js (https://angularjs.org/), so you might want to learn that if you need more complicated web site (99% of people don't, although they they it might be kewl to sprinkle some useless crap to slow down their web site on slower smartphones, which are still prevalent). Still, it doesn't hurt to know what is possible with Angular.


This, mind you, is all on the client - defines the look&feel of your web site. The backend, however, is a different beast. ASP.NET MVC is a good start, since Microsoft have a ton of tutorials and it is easy to get started. If you don't like it, there's Django (if you are familiar with Python), Rails (if you prefer Ruby), CakePHP (if you are familiar with PHP), and.. I'm not a Java person, but I've heard of Spring. Pick the one whose programming language you are most familiar with and you'll find a lot of tutorials online.


Remember, you don't need complicated and fancy stuff just because everybody else is doing it.


Firebug is your best buddy for client web development :)


Now, these are more more complicated advices, so you might want to ignore them at first. Make your site work fast, make it work beautifully on smartphones/tablets via responsive design and don't overuse javascript. Web sites are fast if you do stuff with CSS, not Javascript, and also if you don't use AJAX for everything (if at all). Learn about bundling and minifying javascript/css, learn to use spritesheets with CSS for your images (if you are curious, look at the images in facebook). The goal, just like game programming, is to reduce the number of requests the browser makes to the server for files. The less files the browser has to download, the better. If something is static, put it in CDN. If parts of your site are static, cache them (different serves use different technologies to achieve this).