Collision from Under Another Actor

Talk about making games.

Collision from Under Another Actor

Postby GuybrushThreepwood » Sat Mar 14, 2015 9:28 pm

I've been working on a game with fairly large maps, so making it all out of tiles was too much for gameEditor to handle. So instead, I made it all one large image, and have two actors, one as the floor and one as the walls. This works fine, and I have it set up for my character to stop when he hits a wall. Herein lies the problem. I made the map with black being the transparent colour. I didn't think it would be a problem, but a lot of the edges of the walls have black on it, which causes problems like my character passing right through them. So what I've done is made the entire "wall" actor solid, so now the black parts are solid. This makes the character just fly off the screen because he's now constantly in contact with the "walls". So I'm wondering if there's a way that I can stop the collision effect from happening when the "wall" actor has a lower z depth than the "floor" actor, without having to re-do the entire world map.

Any help would be appreciated! :mrgreen:
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Collision from Under Another Actor

Postby skydereign » Sun Mar 15, 2015 12:16 am

GuybrushThreepwood wrote:So I'm wondering if there's a way that I can stop the collision effect from happening when the "wall" actor has a lower z depth than the "floor" actor, without having to re-do the entire world map.

There kind of is through getactor, but I don't recommend it. You would at that point have to write your own collision system on top of it to know when to allow or disable collisions. Really the way to go sounds like having your wall image have an alpha channel so that black doesn't get set to transparent (or use an unused color for transparency).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision from Under Another Actor

Postby GuybrushThreepwood » Mon Mar 16, 2015 5:50 am

I was hopping that wasn't the answer, because the black is also the background colour, so it will just be a lot of work making sure the black I want to be black to stay black. Thanks for your help!
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Collision from Under Another Actor

Postby bat78 » Mon Mar 16, 2015 5:55 pm

Game editor has no control variable for zdepth, which means you can not "getActorZdepth".
However, you can create one global variable (e.g double player_zdepth;) and set player´s zdepth constantly to a specific value using
ChangeZDepth("player", (player_zdepth = 0.000000));
On that way you will keep track of the player´s zdepth using a variable.
________________________________________________________________________________________________________________________________________________
You said you have the image of your walls?
I have good news for you. The major project I am working on can load the entire image in runtime in buffer and you use a function to get color at x/y.
Unfortunately loading x32 bit PNGs (those with alpha channels) is a feature that will be supported in the next version of it.
On the other hand, black is a 0.0.0 color and even with alpha chanel, it will be easy to determine it, hence in that case, alpha will be simply ignored.
So you can pretty much convert your image to a bmp and this will work as long as you don´t want to return the actual transparent color, but simply if it is black or not.
________________________________________________________________________________________________________________________________________________
Yes, you can turn off collision:
EventDisable("player", EVENTCOLLISION);
or/and
EventDisable("Event Actor", EVENTCOLLISIONFINISH);
and their Enable analogue.
________________________________________________________________________________________________________________________________________________
Using my project a raw code would be like:
Code: Select all
int player_touches_color;
int black_color = 0;

DWORD bgHeight = bitfox_get_height_data(BMPDATA[WALLS]);
RGB trio = bitfox_getcolor_xy_data(BMPDATA[WALLS], player.xscreen, bgHeight - player.yscreen);

((unsigned char*)&player_touches_color)[0] = trio.R;
((unsigned char*)&player_touches_color)[1] = trio.G;
((unsigned char*)&player_touches_color)[2] = trio.B;

if(player_touches_color == black_color)
    EventDisable("player", EVENTCOLLISION);
else
    EventEnable("player", EVENTCOLLISION);

Of course, there will be much more elegant way to do so.. this is just a raw view of how it works. This will stop doing any collision effect if player is in touch with black.
You can play with the condition and make it dependable of the zdepth as I exemplified above. I am giving you a view of one possible way. If you want this code to work you will have to wait for the project release, which is going to be soon anyway.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Collision from Under Another Actor

Postby speckford123 » Fri Apr 17, 2015 3:07 pm

I always did it a lazy way and put collision events in the main player in script editor with
if(collide.wall==1)

So then I can just switch wall=1; on any actor that I want to be a wall and switch it off with wall=0;
it's probably a bad way to do things, but it gets me by, haha
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest