Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Following two objects at once

Author
Message
bacteriaman
9
Years of Service
User Offline
Joined: 2nd Feb 2015
Location: Vancouver WA
Posted: 2nd Feb 2015 06:43
Hello.

I purchased AGK2 a few months ago and finally getting around to using it. I'm new to AGK2, but not new to game development or programming in general.

I have spent some time with some AppGameKit tutorials and now feel comfortable enough to start my first game. I have several game ideas mulling around in my head and have decided to focus on one in particular.

My game will consist of two main objects: one is player controlled and the other is computer controlled. The goal of each level is to keep the two objects as close together as possible while navigating the playfield to a destination point. The player cannot control or manipulate the computer object directly, but instead will use various methods to coax it along.

That said, my game engine needs the ability to scroll and follow both objects at once from an overhead perspective. Both objects need to be kept on the screen at all times by zooming the playfield in (when close together) and out to a maximum viewpoint. All objects (including obstacles) will scale while zooming to stay in-sync with the background.

What's the best way to get started? Is there a tutorial to demonstrate the above? I don't mind cutting this overall objective into smaller pieces.

All comments and suggestions welcome. Thanks!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2015 10:33 Edited at: 6th Feb 2015 10:38
It's your lucky day...or lucky choice of programming language.

Check out the following 2 commands in the help, in the core section:

SetViewZoom
SetViewZoomMode


To move around the playing field:

SetViewOffset

You will also want to look up these for converting what you see on the screen, to where you are in your world, and vice versa:

ScreenToWorldX / ScreenToWorldY
WorldToScreenX / WorldToScreenY


and possibly for your scores, lives etc:

FixTextToScreen
FixSpriteToScreen


Quidquid latine dictum sit, altum sonatur
bacteriaman
9
Years of Service
User Offline
Joined: 2nd Feb 2015
Location: Vancouver WA
Posted: 2nd Feb 2015 21:55
@BatVink,

Wow, lucky for me indeed.

It's great to hear AppGameKit is going to do most of the heavy lifting for me.

I'm anxious to get started with your suggestions and I will report back with my progress (and perhaps a follow-up question or two.)

Cheers,
John
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 6th Feb 2015 10:11
I'm sure you've found it already, but you can use SetViewOffset for scrolling around the playfield.

V2 T1 (Mostly)
Uzmadesign
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Feb 2015 10:39
Good point, I've edited my original post with this for anyone else reading at a later date.

Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2024-05-19 03:24:29
Your offset time is: 2024-05-19 03:24:29