Game Development Community

Mouse Control?

by Phil M · in TGB Platformer Kit · 11/23/2008 (11:51 am) · 10 replies

Hi,

I'm new to TGB & PSK, got them a day a go & have been hooked! This is an excellent extra add-on to speed up the whole platformer creation process. I've learnt lots about TGB already, & platformers in general! Well worth the extra money ; )

I'm actually looking to use it with iTGB (I won't go into anything iTGB specific as that's for the private forums I believe), and have managed to get the basics working without resources.

What I now need to do is control the player via a mouse input, and have some crude test examples working, but wondered if anyone had tried it or had any advise on how you could write a mouse control behavior rather than keyboard based one.

I'm basing my script on the mouseDraggable.cs behavior, and have been adapting from that. E.g you click & drag to send the player one way, keeping your finger down & moving the opposite way flips the player run direction. Same with up & down for duck/jump.

I'd also like to play with alternate mouse button control, so you could just click an onscreen left/right/jump button (which I presume would be much easier to implement than the mouse drag option).

I know this isn't all PSK specific, but thought it would be a good potential add-on, to develop a mouse control behavior to extend/replace the keyboard one for this type of situation.

I think I need to understand how PSK works in regards to the player controls, and variables associated with it, before I can get anything really usable. Having a little trouble with the jump routine. I will persist though..

Any tips/pointers/ideas greatly appreciated!

Thanks,
Phil

About the author


#1
12/01/2008 (2:29 pm)
Hi Phil,

It sounds like we're both trying to solve the same problem, as I assume you want mouse interaction to simulate the accelerometer functionality in the iphone/itouch. (At least that's my plan!) I haven't started on that aspect yet but if I figure something out in relation to the PSK I'll be sure to share the code with you.

Good luck, Russell
#2
12/01/2008 (2:47 pm)
Aww crud, I kept forgetting to respond to this post. I actually have some code that will do what you guys are asking.

What I did was add a "moveTo" function which uses the Actor's controller to move him around. Think of it as a really basic pathing scheme for AI, or in this case, point and click movement. It doesn't do anything fancy like jump over obsticles, all it does is try to get close to the target point.

Unfortunately, you have to remember that the iPhone has problems with TorqueScript (in that it performs pretty poorly). In its current form, the PSK won't really work too well on the iPhone. Which is kinda crap!
#3
12/01/2008 (3:25 pm)
Hi guys,

Thanks for replying.

The moveTo function sounds very useful for a side scrolling rpg type of game, which I'm actually considering anyway, so would be very interested in that.

I suppose what I'm more looking at for my current idea (& should have made clearer) is more swipe detection (thinking along the lines of iphone game play).

As Russell mentioned (I think we're trying to get slightly different things, although they require similar changes/additions to PSK) some way to get the accelerometer / tilt mechanism or the touch input hooked up easily to the player sprite.

My current angle is touch focused - where you drag your finger (or click, hold your mouse button down & drag) say left across the screen & the player walks in that direction for as long as your finger is down. If you stop dragging but keep your finger down the player continues. If you flick/move your finger right, whilst still holding down, the character changes direction. I suppose this doesn't translate so well to the desktop side of gaming, its more of a simple gesture control system I suppose.

Or otherwise simulated buttons (or d-pad) on the screen that you tap with your finger (or click with your mouse). I guess this is outside PSK & should be do-able with normal TGB features. Not looked into this yet...

As for running speed, yes TorqueScript currently runs poorly on the handset for now, but I believe improvements are being made on this aspect for next update, and things can be re-written in native objective-c (I believe) to get massive speed boosts. Which I'm more than happy to approach once I understand iTGB & PSK alittle more, and if no one else here gets to it before me ; )

I think PSK has alot of potential with iTGB, and think its worth trying to at least port the concepts of it over for use on the handset. Hopefully future developments mean native TorqueScript will run ok. With mainly customisations of the graphics and certain scripts needed to get the maximum performance.

Thanks again for making this sweet little add-on ; )
#4
12/07/2008 (10:33 am)
Quick update on my PSK speed tests with iTGB so far.

After initially trying to run the default PSK package (without resources, instead manually importing minimal game art) on the handset and getting unusable speeds, I went back to basics & got a version of the old platformer tutorial running at an ok speed.

I've since started to import minimal PSK scripts back in, and before enabling actual platforms or character controls, run the test on the handset at reduced, but almost usable speeds. I will be go through & trying to disable feature like sound for now, to see how much they improve performance.

I've also taken a look at the iTGB Behavior Shooter demo that makes use of components (converting some TorqueScript behavious into c++), which shows some nice speed boosts over the non-optimised one. I noticed that they are actually using a couple of the PSK behaviors (with credit/copyright given to you Philip), and these have been converted to c++ already. So it shows promise for PSK as a whole : )

Do you have access to the iTGB private forums Philip, as that may be a better place to discuss these bits?
#5
12/07/2008 (10:50 am)
Yeah, porting to iPhone is a bit of an uphill battle right now but I appreciate that GG got the software out to at least start testing basic functionality. Just rethinking user input possibilities is more than enough to chew on, at least for me. At the risk of sounding like a turncoat or igniting some sort of flamewar I've also been looking into Unity's offering for iphone dev and it seems quite robust. I suppose that's the advantage of being a mac only dev shop, there's less translation work to be done to get things out the door. Of course the disadvantage with Unity is it's 3D oriented so you more or less lose the ability to express your game world using sprites only. Still, the real time editing tools are useful for prototyping so it may be that you could just consider it just another tool in your arsenal.
#6
12/07/2008 (3:05 pm)
*shudder*

Lets keep this to a PSK discussion!

Quote:I noticed that they are actually using a couple of the PSK behaviors (with credit/copyright given to you Philip), and these have been converted to c++ already.

Errrrrrrrrrrrrr... That is the first that I have heard about it. Might I ask which components that might be PSK related were shipped with iTGB?
#7
12/08/2008 (7:38 am)
Sorry! I love TGB and the PSK, honest!
#8
12/08/2008 (4:10 pm)
Apologies Philip, thought you might have had something to do with the iTGB tweaks which is why I asked this here.

Has a GG employee contacted you about this? I've tried to contact them myself. Don't want to get anyone in trouble here on either side...

The PSK bits I spotted were sent in a separate demo that was only just uploaded to existing iTGB users in the private forums. This may well have been a mistake in packaging, not sure if the actual example makes use of the code, or if it was mistakenly left in.

Hopefully someone has got hold of you to remedy this!
#9
12/08/2008 (4:55 pm)
No one will get in trouble, I don't have a problem with some of the things that I have done being used. I just hope none of the PSK specific elements have been distributed to people who don't own the PSK!.

A while ago, I did some work for Paul on converting a few of the PSK behaviors to components. The main one was the new ActorComponent which improved the efficiency of the PSK's actors and overall FPS.
#10
12/11/2008 (4:37 pm)
Ah, that explains it. It must be those components their making use of.
Still trying to wrap my head around that aspect of the engine!