★ TouchArcade needs your help. Click here to support us on Patreon.

Developing Box2D game, and Introduction

11-23-2009, 03:18 PM
Joined: Nov 2009
Location: Czech Republic
Posts: 87
Developing Box2D game, and Introduction

Hi Forum,

My name is Kenn, I'm in the last week of developing my first iPhone game. I hope to share it with you. It's a Cocos2D / Box2D fusion. Currently I'm tweaking the AI to produce better 'intercept' results than my math allows

The games I see on Touch Arcade are just of incredible quality. I look forward to participating.

On the target issue, is anyone familiar with Box2D and calculating intercept code?

11-23-2009, 06:19 PM
I'm not quite sure I understand what you are asking. I know a bit about Box2D and Chipmunk. I know what intercept code is, and I know how it applies to AI. However, your question lacks specifics.

A ragdoll physics platformer:Flickitty
The artist: randall schleufer
Twitter: @FlickittyiPhone
11-24-2009, 04:26 AM
Joined: Aug 2009
Location: Dublin, Ireland
Posts: 46
Assuming this is also your thread on the Cocos2D forums, and just going over your code, where you have:

if(predictLoc.x >= opponentPos.x) {
	// go right - mod X vector
	lateralMod = predictLoc.x; // this works very well consistently
} else {
	// go left - mod X vector
	lateralMod = -(predictLoc.x); // is this correct for moving to screen left?
Is likely the problem. For moving to the left, you shouldn't need to take the negative coordinate, or really do anything different at all from moving to the right. You seem to be predicting the location accurately enough, so your value will already have the correct sign. By negating it you're making it go off. So instead you could probably take out the if/else entirely and just have:

lateralMod = predictLoc.x;
The value will effectively perform the logic for you.

-- DaVoid Digital --
Check out AstroSerf - Update now available!
>> For more information, mosey on over to AstroSerf.com
>> Follow AstroSerfGame on Twitter for the latest news!
11-30-2009, 05:17 PM
Joined: Nov 2009
Location: Czech Republic
Posts: 87
Hi Dawvee, yes it is. Thanks for quoting the code. I didn't want to clutter up the forums too much here.

I tried your idea, which makes perfect sense, and get an odd result with my goalie hugging screen right. The negative transformation moves my goalie to screen left ok.

I did notice my Y values seem too high (25 say)while the X is very low, 1 or 0.9. For a lark I switched the x and y values in lateralMod and it's actually more accurate on the screen right. So my math or method is off, probably in an obvious way.

I set up my goalie AI process like this:
1. Calculate the predictedLocation,
2. Make a decision according to where the puck is in relation to itself,
3. Set up a switch statement to set a new state (Attack or defense),
4. Make any mods to the numbers (Danger!), then
5. Move the goalie.
Later I'll be adding other AI modes and this helps me keep it in order.

The game's far enough along to start posting play videos, so I'll be able to show and tell.

Hi Flickitty, great game btw, and style. Thanks guys.

IndieGogo Campaign for concept art: Cannon Berserker
Dev blog: http://blog.xyris.ca
SteamPunk Hockey screens, video, reviews: http://steampunkhockey.com/screenshots/
Twitter: @XyrisKenn