Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, April 16, 2012

Episode 9 - Baptizing Bots, Cursing C++ Updates, Shrinking Songs

Awesome bot names

Team Trivia features, at least in the initial testing phase, bots. These cool little automatons will fill up your team to 4 players whenever there are not enough human players available in the lobby.

To give the bots a bit of personality I wrote a simple syllable-based random name generator. The generation is based on three arrays with syllables taken from the characters of the Oz books. Some of the entries are deliberately empty to create two-syllable words. All in all, nothing fancy, but I really like the names it spits out.



Update from hell - Visual Studio SP1

Time for a rant. I wanted to try building http://1337haxorz.de/products.html and then using it (one way or another) from Delphi. I don't have a decent C++ compiler on this laptop yet, so I downloaded Visual C++ 2010 Express and installed it. Which was a nice and smooth ride, but then... I run it.

First off, it complained about finding other Visual Studio 2010 components running on the system, but ooooh those were SP1, so Visual C++ couldn't run until it was updated as well. Excuse me? I just want to compile some standalone C++ code, do I really care about the exact update version of ASP.net or SQL Server? If it is so darn important that "everything runs on the exact same version", why have me download an outdated version in the first place? But ok, I'll click the button on the dialog that downloads SP1 and install it...

... which apparently takes 4x as long as doing the full Visual C++ 2010 Express installation in the first place. Oh, and it requires a reboot too...

... which then ends in a black-screen-with-mouse-cursor, where it is installing stuff without any visual feedback (i.e. "it just sits there"), for well over an hour! Dear developer people designing this install process, please realize that this sort of user experience is Unacceptable. I can't use my machine (it zapped about _all_ the personal coding time I get on a weeknight), I haven't got a clue how long it is going to take, and most importantly: I'm seriously worried! Is it still running? Is it breaking just my Visual Studio, or trashing my hard disk completely? Will my machine ever come out of it, again?

If you are going to lock me out of my own machine for this amount of time, at least have the decency to warn me beforehand, but even then... what the heck are you installing on my machine that takes so frighteningly long? The entire MSDN?


 
Building a tiny V2 executable with VS2010

As Fabian "Ryg"Giesen just published loads of Farbrausch tools on GitHub, all of this will probably become irrelevant really fast, but here is how you do it:

Prerequisites
- Install Visual C++ 2010 express. Gnash teeth whilst enduring any SP1 updates.
- Get nasm. Install it anywhere, but make sure to put the location into the path.
- Copy nasm.exe to nasmw.exe. This is probably not the best way to do this, but it works.
- Get the official kkrunchy binary from ryg's Homepage . Put anywhere on your disk.
- Get the V2 sources . Again, the project is now on Github, so you might want to pull it from there.

Building
- Open up example/tinyplayer.sln from the V2 source folder. Visual C++ will automatically upgrade the solution to 2010
- Open up the project property pages.
- Change the Base Address to 0x800000 (or anything significantly bigger than the default 0x400000, really). This will suppress kkrunchy's warning about the resulting executable not working on win 9x.
- Change the Randomized Base Address to No (/DYNAMICBASE:NO). If you leave this setting on th default Yes, the kkrunched executable will immediately crash when started.



- Close the property pages and build the project (F7).
- Open up a CMD prompt, run kkrunchy on the resulting tinyplayer.exe . Done. 16kb of tiny music madness.


Monday, April 9, 2012

Episode 8 - A better stopwatch, character encoding

A better Windows 7 Stopwatch - Stopwatch7


To celebrate Easter, my trusty XNote Stopwatch decided to malfunction (no, I didn't actually take 1193 hours to write this blog post). Instant panic! I absolute need some sort of time measurement at home, because with all the interruptions in a day (kids, kids, wife, chores, kids, more kids) my sense of time goes all funny, and I start to feel like accomplishing nothing at all.

My demands for such a tool are simple: it should be simple, trivial to start, trivial to stop, and should always be visible, yet not in an immensely intrusive way. I dare you to look for such a timer on the internet, I bet you won't find it. I know I haven't.

So I happily jumped into the most alluring of developer pitfalls, and rolled my own. Against all Windows guidelines I write the time progress straight onto the taskbar (heck, my taskbar icon is prime screen estate!) At a later phase I'll probably add a better peek thumbnail, including some nice thumbbuttons and global hotkeys... but for now this solves my problem.


If you want to play around with it, you can download it here. The lovely icon is by Oliver Scholtz .


Character encoding - always a worry

Some of the questions in the Team Trivia database contained evil Word-style quotes. Those questions would be displayed at the client as a lovely "null"... which makes providing the proper answer rather difficult.

After a quick scavenging hunt across the different application layers I learned how PHP's json_decode will silently and happily replace a string of text with null if it contains anything other than UTF-8 characters. As MySQL defaults to latin1 (ISO 8859-1), this explained the troubles.

Adding a mysql_query('SET CHARACTER SET utf8') at a tactical location fixed things up nicely.


Misc

- Registered ShinyHammerGames.com, registered myself as a Google Play Developer .
- This blog is now hosted on blog.shinyhammergames.com .
- NetBeans has integrated MySQL management ... but it refused to show me the table data of some of my tables, was horrible for proper editing of text data, and is rather short on functionality anyway. I've fallen back onto my trusted friend SQLyog Community Edition .
- Got bitten by the backticks-versus-single-quote semantics of PHP/MySQL, referring to random columns in a WHERE clause. That's what you get for developing on a tiny 13" laptop screen.

Sunday, March 18, 2012

Episode 7 - Coordinates, New Project, PHP Setup

Revised Coordinate System

Ok, so it turned out my coordinate woos from Episode 4 were indeed "woos", it turned out the coordinate system I implemented before was totally impractical. Here is what I do now:
  • I simply provide the render system with a desired virtual resolution (800x480 in my case) for the view
  • The size of all sprites is interpreted relative to this resolution, i.e. a 80x48 bitmap sprite is 1/10th of the view
  • The render engine automatically applies letterboxing and pillarboxing on systems running a different aspect ratio, to prevent stretching
  • The upper left corner of the screen is at (0, 0), because this is the traditional approach I've been comfortable with since the days of the C64. There will be a flexible camera at a later stage, so this is not set in stone.

Letterboxing on an extra wide viewport

Kicked off a New Project.

I'm trying to get into the habit of starting and finishing short, smaller-scoped projects... so after a (fun!) little brainstorm session with Ye Balde Scribe I've set aside Seesaw Kiwi for the moment, and started a Brand New Shiny Project (tm).

The awesome part about this particular project is that it will be shippable at a very early stage, but still leaves room for massive amounts of improvement. Awesome!


Setting up PHP Development - NetBeans, XAMPP


The new project requires a server component. PHP seems the obvious choice for now, simply because it is the easiest/cheapest to setup... I've got more than a couple of Shared Hosting LAMP websites sitting around, doing mostly nothing.

After installing XAMPP, I hit a small hurdle getting Apache to run, because a running TeamViewer service (which I was pretty sure I'd never enabled) hijacked port 80. On a modern Windows 7 developer system it's quite hard to figure out which of the 70-odd running services is the culprit, especially because netstat -ano returned PID 4... which is the System process. Very helpful, netstat.



This being my first experience with XAMPP and the NetBeans IDE, I was a bit disappointed that I had to manually edit php.ini to get the debugger to work (why bundle it with XAMPP but not configure it?). And why do I have to manually edit httpd.conf to get the active NetBeans project running in Apache? Can I have my IDE a bit more Integrated, please? Good news: the debugging experience is really good thus far.

Rant: it's kinda unfunny how windows projects that originate as Cross Platform Open Source never seem to get UAC right. Same with XAMPP: You have to make sure you don´t install it inside Program Files (because it drops read/write config files inside it's install directory, which is a big no-no in Windows-land), and you need to explicitly launch the XAMPP control panel with elevated rights because it needs to manipulate windows services, and doesn't include a manifest of its own.

Oh well, enough complaining, it's free and it works. Hopefully the Mac/Linux users get a bit more love for their respective platform guidelines :-).


Misc