Color & Gravity Switch

Non-platform specific questions.

Color & Gravity Switch

Postby BS87 » Thu Aug 18, 2011 5:39 pm

Hi there,

as some of you already helped me in another thread with more basic questions, you may already know my game. The jumping and tile collision now works pretty much (some collision bugs that need to be terminated are still going on) and I'm ready to advance:
The game is a simple puzzle-platformer (inspired by VVVVV) and consists of two player-controlled characters. As soon as one of them hits a switch in the level, I want the following two things to happen:

1. Color palette swap
I want to have the whole level to kinda get a "different lightning". For that I created different colored tiles and character models. The level background should probably change too, if this is possible. I read about using custom backgrounds (which would be no problem since it's a single color anyway), which would open the possibility to just create two different colored ones and make them swap by event, I still don't know how to do that yet, however.
The tiles seem to be more of a problem since I couldn't find a tile swap command in the script editor. Concerning the color of the characters changing I have an idea which I will explain in the second event for hitting the switch:

2. Gravity switch
When ONE character hits a switch, I want them to BOTH change the gravity to upwards/downwards. Simply changing the velocity would be an option. Since I however also want them to change their color, I thought about completely destroying the actor and replacing it by another one at the same position (Means you got two "green" characters with normal gravity and two "red" ones with reversed gravity) whenever a switch is hit. Would this be a good solution and what would be the commands to achieve that? (Another problem I'll probably encounter will affect that the freshly spawned "upside down" character instantly hits the switch again and reverses the event, but one problem after the other I guess).

Thanks for the great help I got already!
BS87
BS87
 
Posts: 8
Joined: Thu Aug 04, 2011 2:12 pm
Score: 0 Give a positive score

Re: Color & Gravity Switch

Postby skydereign » Thu Aug 18, 2011 9:37 pm

Well if you are using tiles, then you can't change a tiled actor's animation. You can do one of two things though. If your initial tiles were all whiteish, you can change the level's color by changing the tiled actor's rgb values. To change an actor's rgb values just do something like this.
Code: Select all
tiles.r=255;
tiles.g=0;
tiles.b=0;

The other option is a little more... annoying. You'd have to use a clone, or different actor, give it the new tiles, and recreate the level. Then when in game you can decide which actor to show, and which ones to disable. The ones that you disable you'd probably use VisiblityState to disable them.

Again for the gravity switch/color change, you can use the same actor, and change the rgb values if the colors of the images you want don't have multiple colors in it (as changing rgb won't work with that). If not, I would suggest creating a single actor, that does everything, and give it a basic set of animations. Then, have all your different colored actors inherit their events from it (near the bottom of the Actor Control panel), and give them the different colored animations. And I'm not sure if you mean you are creating a different actor for the different gravity, if so, I wouldn't. If you have two way gravity, have a variable that determines the direction of gravity (1 for normal, -1 for reverse).
player -> Draw Actor -> Script Editor
Code: Select all
yvelocity+=gravity;


Of course each event would use the gravity to change know if they should change their animation to upside down, or not. If you prefer to not have to do that, you can still use inheritance, but you'd need to make two actors, and have your other actors inherit from them.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Color & Gravity Switch

Postby BS87 » Fri Aug 19, 2011 4:22 pm

Hey there. The rgb method was actually one of the first things I tried but since my tiles are multicolored it didnt work out that good. The "annoying" method you suggested worked, however. I created a custom background (two different colored versions) and recreated the level with different colored tiles (for my game it actually isn't "annoying" at all since the levels are pretty simple and small). As soon as one of the characters hits a switch I just let background and tiles switch their z values and they appear/disappear. In the next days I'm going to fumble around with the gravity switch and the characters changing their apperance (which will be way harder for a newb like me).
I uploaded the current version of my game HERE (attachement function on this page always gives me 503 error, sorry) for you guys to check it out. Characters are moved with wasd & arrow keys. The right switch seems to spaz out the sound, even after switching the collision repeat to off, but as long as I get everything to work I can overlook small bugs like that (as I said before this whole game is just a little project for a university course I'm taking).

Thanks for the help so far and keep the support coming, I need (and use) every bit of help I can get!
BS87
BS87
 
Posts: 8
Joined: Thu Aug 04, 2011 2:12 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest