Gorilla3D

Blogs of my work and thoughts

My First iPhone Game Part#2

So I started to draw some thoughts on controls. It would be nice to have the player just press and drag the character to where they want. This would act a lot like Google Map's little yellow man. I have always found it painful to implant controls on top of the game screen, because there is no physical indicator to tell your finger is not longer in the bound of the control, its hard to know until your character stops. Then your lost for a few seconds seeing what finger is doing the wrong thing. When in a stressful situation its so easy to have this happen promoting death and frustration to the end user. There is always the notion of walking in a game, but if your just dropping your character everywhere you lose that delay. I am expecting to implement that delay by the screen panning to the center of the character. While the screen is panning you'll lose the ability to move your character. I could also super impose a limited drop range. This could be effected by the weight of items in your bag, or special attributes like dexterity. It would also work in multi-player situations, as the the screen is panning the character would really be moving on the other player's screen. It would be interesting to see as this is a lot like chess. You'd have to expect where the other opponent would be moving to, to cast your spell, shoot your bow, or run from.

I've been messing with the DragonFire SDK a bit more and still pondering the question of how to manage views, images, text, etc when you don't need them other then making them invisible. I've been busy wrapping the SDK into c++ classes. Their SDK is c based, so although you can use c++ with it, you're not in a very good position unless you do extra work like I am.

Here my c++ wrapper work on their SDK
Shabb::View v = Shabb::View("Ball.png");
v.getWidth();
v.setX(23);
v.setTouch(OnTouched);


Here is the c code for the same functionality as above.
int v = ViewAdd("Ball.png", 0, 0);
int width = ViewGetWidth(v);
ViewSetxy(v, 23, ViewGety(v));
int TouchHandle = TouchAdd(0, 0, ViewGetWidth(v), ViewGetHeight(v), OnTouched, 0);
int ViewSetTouch(ViewHandle, TouchHandle); 


I've also went ahead and upgraded to their Ultimate Iphone package since I've been reading about bad experiences with the SDK. I've been down this boat before (Titanium Mobile SDK) and so I would like to test on my device early before I complete the game and find out something I did, needs to be junked. It took a little over a day, to register my device (just like their website says). I used their contact form to email them and 3 days later no response. So I just emailed them directly and 10 minutes later I got a response. Their site states 6 hours, so overall that is a great response time. I did get a quick demo to compile on their server. I successfully installed it on my phone and overall excited to see it really worked. Again coming from Titanium Mobile SDK, setup is so easy and really just amazing. However the build process is very tedious. Once your ready to test on your device, you upload it to their server you get the file in about 10-20 seconds. Make sure you click and spam the "Check Status", because refreshing the page will have you sitting there for hours. Once I got the demo running I started on my own game. I quickly found it crashing on my device and not the emulator. After 2 hours of zipping, uploading, unzipping, dragging, replacing and rerunning, I got it to not crash. It was over a stupid printf call.

Here is what I had:
	std::map<std::string, Shabb::View>::iterator p;

	for(p = sviews.begin(); p != sviews.end(); p++) {
		std::string name = p->first;
		Shabb::View v = p->second;
		v.hide();
		printf("Deleting: %s\n", name);
	}


Here is the resulting code that worked:
	std::map<std::string, Shabb::View>::iterator p;

	for(p = sviews.begin(); p != sviews.end(); p++) {
		std::string name = p->first;
		Shabb::View v = p->second;
		v.hide();
		printf("Deleting: %s\n", name.c_str());
	}


Now with the visual c++ compiler, the output of the printf resulted in funky characters. I thought nothing of it, just was a weird thing. Well turns out, it wasn't just a fluke, since it resulted in a crash on iOS. There is not a compile error, and I don't receive the log from the build system when completed. Overall this was about 2 hours of work, I felt like a real programmer, "Real programmers don't use debuggers". Obviously its not a fun process, hopefully I will become better at this and avoid stupid mistakes.

I would love to see their starter SDK free as I can see a huge up taking on this when it comes to making games even on the PC. Their SDK is lightweight, simple and so far is great.

Until Next Time,
~ Joseph Montanez

My First iPhone Game Part#1My First iPhone Game Part#3