The Daily Click ::. Forums ::. Klik Coding Help ::. make if facing object
 

Post Reply  Post Oekaki 
 

Posted By Message

Jake Jilg



Registered
  12/06/2003
Points
  53
10th August, 2006 at 15:15:48 -

I hope I can describe my problem good. I'm using TGF, and I making a game so when you click a button when the hero (8direction) is overlapping an object, say like a treasure chest or something, but I only want the action to happen if the hero is generally facing that object to interact with.

I managed making a crappy system of making 4 events with the same actions. It's based on the hero's X,Y position and direction facing. But I don't want to make four events with the same action. I have tons of objects to interact with and I want to make just one event for each. Is there a better way, or like an extension I can use. I don't care if you get really complicated with me, I'll take what I can get.

 
zeeky boogy doog

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
10th August, 2006 at 16:21:42 -

You could have an overlap detector ( a small 2x2 square that sets itself to a position relative to the player depending on the direction i.e top right of the sprite if facing north-east)
and then:
Compare two general values : Direction of Player = Direction of object + 16
+ Detector is overlapping object
= Do something


A shite way that may not work, you could probably do a more effective using a fast loop system. Maybe

 
My signature is never too big!!!

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
10th August, 2006 at 17:39:11 -

Or you could do it this way.

Make a detector that sticks out in front of your player a bit. Rotate it (Usually, I use a small circle with a hotspot that's sunk way back away from the graphic; so that you can just tell TGF to set it at 0,0 from the player, and not have to mess around with math.)

Always - Set X,Y of Detector to X,Y or Player
Set Direction of Detector to Direciton of Player

 
Craps, I'm an old man!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
10th August, 2006 at 21:12:32 -

Or you could have it real simple like most RPG games where the chest is always facing south and the hero has to open it looking upwards. Just have the event check to see if the hero and chest collide, as well as if the hero is facing in the up direction. That should work okay.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Jake Jilg



Registered
  12/06/2003
Points
  53
11th August, 2006 at 07:03:25 -

thanks all of you! I will definately try these ideas!

 
zeeky boogy doog

Werbad



Registered
  18/09/2002
Points
  235
11th August, 2006 at 16:52:02 -

Direction of Player = Direction of object + 16 will only work for half of the directions... if the objects direction is 16 or higher it won't work

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
11th August, 2006 at 17:17:09 -

@Del - But then your character would be on top of the chest instead of facing it. Keep in mind my idea is best used for a tile based engines; I don't think I actually said that though, so I'll correct it now.

 
Craps, I'm an old man!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
11th August, 2006 at 19:18:49 -

Ooops, you're right!

The way I'm doing the chests for Necropolis Rising now is that the actual treasure contents are set on the ground, and then a separate chest active is placed on top of the item. When the necro and the chest collide, the necro's movement stops. Chests can be opened with the Breaklock spell (also how you can open locked doors), which is basically an AoE spell. If the spell's field collides with a chest, it does an opening animation and then gets destroyed, revealing the treasure inside (or underneath, to be more exact). Thankfully I don't have to worry about direction in order to open them. Dragon Quest 8 does make it so you have to be facing the chest in order to open it, but honestly I think it's sort of a minor pain.

One of these days I would like to try a tile based game in MMF. I've done some maps using tiles for the Equin games, and they're basically a set of large double-dimensonal arrays that hold a 3 length long string. Example: O12 = O (for outside), and 12 (12th outside picture, say a tree or something). Does your tile engine use similar arrays to store the information Knudde?

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
11th August, 2006 at 19:19:37 -

Dude, you want a tile based Strat RPG engine.

It's horribly complicated, but it should give you an idea.

 
Craps, I'm an old man!

Nova Soft



Registered
  16/10/2005
Points
  427
11th August, 2006 at 20:30:23 -

Image

 
By a route obscure and lonely,
Haunted by ill angels only,
Where an Eidolon, named night,
On a black throne reigns upright,
I have reached these lands but newly
From an ultimate dim Thule
From a wild clime that lieth, sublime,
Out of space
Out of time.

deadeye



Registered
  22/07/2006
Points
  73
11th August, 2006 at 20:40:19 -

Nice purple penis there, NovaSoft :/

 
n/a

Nova Soft



Registered
  16/10/2005
Points
  427
11th August, 2006 at 20:55:07 -

Thank you my boy! *kiss*

 
By a route obscure and lonely,
Haunted by ill angels only,
Where an Eidolon, named night,
On a black throne reigns upright,
I have reached these lands but newly
From an ultimate dim Thule
From a wild clime that lieth, sublime,
Out of space
Out of time.
   

Post Reply



 



Advertisement

Worth A Click