YolkfolkThe Dizzy Fansite
Community discussion

Climbing up and down

Started by Grandad on 23 November 2009 • 29,066 views

54 posts
#82057

I've had a look Grandad and I reckon what's needed is in there somewhere. I'll see what I can do with it (although I'll no doubt be back on here asking for help in no time!) Thanks!

EDIT:

And two hours later here I am! This first part uses a collider with ID 750 that is where the hanging whip is on the map. Dizzy hits it, the "Dizzy player" tile is disabled and the "Hanging Dizzy" (ID 751) tile is displayed.

func CollideObject_750_1( idx )
{
	idx = ObjFind(750);
	x = ObjGet(idx,O_ X) -6;
	y = ObjGet(idx,O_Y)+12;

	PlayerSet(P_STATUS,STATUS_SCRIPTED);
	PlayerSet(P_DISABLE,1);

	chr = ObjFind(751);
	ObjSet(chr,O_X,x+2);
	ObjSet(chr,O_Y,y-16);
	ObjSet(chr,O_DISABLE,0);
	ObjPresent(chr);
	ObjSet(idx,O_STATUS,1);
}

So far so good (as far as I can tell). But this:

func Whiphang()
{
	idx = ObjFind(751);
	if(ObjGet(idx,O_STATUS)==1)
	{
	if(GetKey(KEY_LEFT)==1)
	{
	ClearKeys();
	chrx = ObjFind(751);
	ObjSet(chrx,O_DISABLE,1);
	x = ObjGet(chrx,O_ X) ;
	y = ObjGet(chrx,O_Y);
	PlayerSet(P_X,x);
	PlayerSet(P_Y,y);
	PlayerSet(P_DISABLE,0);
	PlayerEnterJump(-1,3);
	}
}

}

func UpdateRoom_5_1()
{
Whiphang();
}

just doesn't work. To be honest I haven't got a clue whether I'm even using the correct commands but as far as my limited skills tell me, it should be doing SOMETHING when the left key is pressed. But I need help please, am I even close to being on the right track here?! {dizzy}:huh:

👍 0
#82066

Sorry Pogie, my bad! The cling coding is purely for jumping left or right up onto a ledge, hanging there and then either climbing up or dropping down. What you need is a basic version of Colin's climbing code without all the extra movement stuff.

Preparation: Place a dizzy_idle tile on the map at the point where the 'cling' tile will be and make a note of the x and y co-ordinates (make sure the x axis is divisible by 4). Now delete it and place the hanging tile (id 751) in the same place and set it as dynamic and disabled, with an action of 0. This is because you only need the 'picture' when Dizzy is at that position. NB, the 'hanging whip' can be the collide object provided it is placed on the map so that when Dizzy is clinging he is in the 'middle'. Also as it is 'thin' the 'switch' between Dizzy and the 'hanging tile' will be minimal as it is easier to use a mode of 1 when he collides with it.
I haven't included PlayerEnter Scripted in the code as being disabled he can't move, but as he is jumping when he
lands on the whip you do need to set him to idle before his jumps off the whip so that it's a fresh jump.

func CollideObject_750_1()
{
idx = ObjFind(751); //hanging tile
PlayerSet(P_DISABLE, 1);
ObjSet(idx, O_DISABLE, 0);
PlayerSetPos (xxxx,yyyy); // previously noted dizzy idle co-ordinates
WaitFrames(20); // just a tiny pause as he's hangs
if (GetKey(KEY_LEFT) && GetKey(KEY_UP))
{
ObjSet(idx, O_DISABLE, 1);
PlayerSet(P_DISABLE, 0);
PlayerEnterIdle();
PlayerEnterJump(-1,4); // can set the jump power(4) to whatever suits
}
if (GetKey(KEY_RIGHT) && GetKey(KEY_UP))
{
ObjSet(idx, O_DISABLE, 1);
PlayerSet(P_DISABLE, 0);
PlayerEnterIdle();
PlayerEnterJump(1,4); // can set the jump power(4) to whatever suits
}
}

Of course if you want to be a total b****** you could include:

if (GetKey(KEY_DOWN))
{
ObjSet(idx, O_DISABLE, 1);
ObjSet(ObjFind(750), O_DISABLE, 1); //disable collider so Dizzy can fall
PlayerSet(P_DISABLE, 0);
PlayerEnterIdle();
WaitFrames(30); //or whatever time is needed to move off the collider
ObjSet(ObjFind(750), O_DISABLE, 0);
}

so that Dizzy drops off the whip, likewise you can add left only and right only Getkey commands to do the same thing as long as you give give the WaitFrames command anough time for Dizzy to move off the collider. NB WaitFrames doesn't stop Dizzy moving, but will prevent any 'actions' taking place and there are approx 37 frames per second. You don't need the WaitFrames command for when Dizzy jumps as the jump will take him clear of the collider.

👍 0
#82073

Oh no, it's not working!

This is what I've got in game.gs

func CollideObject_25_1()
{
		idx = ObjFind(751);
		PlayerSet(P_DISABLE, 1);
		ObjSet(idx, O_DISABLE, 0);
		PlayerSetPos (1290,216);
		WaitFrames(20);

	if (GetKey(KEY_LEFT) && GetKey(KEY_UP))
	{
		ObjSet(idx, O_DISABLE, 1);
		PlayerSet(P_DISABLE, 0);
		PlayerEnterIdle();
		PlayerEnterJump(-1,4);
	}

	if (GetKey(KEY_RIGHT) && GetKey(KEY_UP))
	{
		ObjSet(idx, O_DISABLE, 1);
		PlayerSet(P_DISABLE, 0);
		PlayerEnterIdle();
		PlayerEnterJump(1,4);
	}
}

I've set the whip (ID 25) as the collider and placed the hanging Dizzy tile (ID 751) on the map as dynamic and disabled.

But when I jump to the hanging whip Dizzy just disappears and the hanging tile doesn't appear! I tried removing the player disable line from the code just to see where he went and he just goes into a small jump as he hits the collider. Hmm {dizzy}:huh:

Apologies for the reformatting of the code, I just find it easier to read this way!!

👍 0
#82076
No problems with amending the layout - I just find it too tedious to keep adding 'tabs'.

You've made a tiny error with the x position as 1290 isn't divisible by four.

Other than there being another tile with id 751 somewhere which the engine is checking, or you accidentally set it to mat, I can't think of any reason as to why it's not appearing. I'd suggest giving it a new number as a check.
👍 0
#82077
Oops, I had set poor Dizzy to "draw none" :blush: so that solved that (and thanks for pointing out my numerical slip up too!)

But the problem remains, Dizzy just hits the whip and hangs there. He doesn't reappear when the left and up keys are pressed (or any key or combination of keys!!) The player disable command works but the player enable command when the keys are pressed doesn't seem to be kicking in. Any ideas (and is it working as it should on your computer?)

EDIT: And also, is it fairly easy to have the hanging Dizzy tile flip to face either the left or right depending on the direction the player jumps from? I had in mind perhaps two colliders next to one another, the left activating the flipped tile and the right being the same as your code above (or maybe I've had too much Christmas pudding and I'm living in a fantasy land!)

EDIT:EDIT: Oh never mind, that wouldn't work because the player would hit the other collider on the jump out the other side. Dizzy would be hanging there forever, flipping back and forth like a fish on a hook.

...Sigh, computer coding is difficult, where's my eggnog?..
👍 0
#82084
Oops, I've just recreated this on a new game template and have the same problem. I'll have a play around and get back to you.
👍 0
#82085

My bad again Pogie - can't do bugger all cos the player's disabled. So have had to come up with a new solution.

Essentially, you're going to have to enable two dynamic hanging whips (one as just a picture with no action and the other as a collider) You have to do this as the only way I can get it to work is by temporarily disabling the collider when he jumps so even though the 'collider' disappears, the 'picture' of the hanging whip is still visible.

Also, you're going to have to switch costumes rather than disable Dizzy and enable a separate 'picture', for that you'll have to use the id of the hanging dizzy tile in the tile folder (eg Dizzy_Idle is tile 10).

func CollideObject_25_2() // note mode 2
{
idx = ObjFind(25);
PlayerSet(P_TILE, 26); //or whatever the tile id is in the tiles folder
PlayerEnterScripted();
if (GetKey(KEY_LEFT) && GetKey(KEY_UP))
{
ObjSet(idx, O_DISABLE, 1);
PlayerEnterIdle();
PlayerEnterJump(-1,4);
WaitFrames(15); //so that dizzy clears the collider
ObjSet(idx, O_DISABLE, 0);
}
if (GetKey(KEY_RIGHT) && GetKey(KEY_UP))
{
ObjSet(idx, O_DISABLE, 1);
PlayerEnterIdle();
PlayerEnterJump(1,4);
WaitFrames(15); //so that dizzy clears the collider
ObjSet(idx, O_DISABLE, 0);
}
}

So, when he lands on the collider Dizzy switches to the hanging view and stays motionless until either the left & Up key or the right & up keys are pressed and he jumps.

If you want to add left only, right only or down key commands, no problem but personally found that a WaitFrames command of 40 is needed to clear the collider.

If you weren't being specific about this game playing like the original, then you could make it a lot harder by just adding

else
{
ObjSet(idx, O_DISABLE, 1);
PlayerEnterIdle();
WaitFrames(40);
ObjSet(idx, O_DISABLE, 0);
}

That way Dizzy will just fall off the whip if the up and left or up and right keys aren't being pressed when he collides with the whip.

I've just thought, if Dizzy going to be able to go back to the village and use the whip when he's wearing the scuba outfit, you'll need to add a 'hanging scuba tile' and use an if command if he's wearing the scuba to determine which tile to switch to.

Hope this helps.

👍 0
#82090
Marvellous, Grandad you've done it again! The only thing that might improve this is to allow the player to use the SPACE key with the LEFT or RIGHT for jumping. But other than that it's fantastic.

And there's no need to worry about the scuba because he doesn't get that until level 3 and once he's there he can't physically get back to level 1!
But the code is marvellous, just marvellous {yolkfolk}:thumb:

EDIT: I found a tiny bug while messing about - if you jump a little way back from the edge and collide with the very bottom of the whip Dizzy just hangs there in mid air and won't respond! It's highly unlikely many players will do this but I thought I'd better point it out!
👍 0
#82093
Thanks Pogie, can't help with the space bar for jumping as I've no idea what 'key' it is when using a GetKey command. But if someone can identify it, you could amend the command to if getkey equals up or getkey equals space and getkey equals right ....etc.

No problem with the whip though, as the 'picture' whip is always present, you can shorten the collider whip at the bottom (and make it mat if you like) so that it only 'registers' when Dizzy is high enough.
👍 0
#82099
I shortened it and although Dizzy doesn't now hang in mid air he is still totally unresponsive. This only happens if he hits the very bottom of the collider and it's not likely to happen very often but it does happen, very strange!
👍 0
#82101
[quote data-userid="279" data-postid="82093"]

can’t help with the space bar for jumping as I’ve no idea what ‘key’ it is when using a GetKey command. But if someone can identify it, you could amend the command to if getkey equals up or getkey equals space and getkey equals right ….etc.

[/quote]

Now I don't want to alarm anybody but I've solved a problem by myself. I know, I know, it's a bit worrying but I'm sure it's a one-off and it's actually incredibly simple so don't fret too much. The line GetKey(KEY_UP)) just needs to be changed to GetKey(KEY_JUMP)) and that covers both the space bar and the up keys.

Crikey.
👍 0
#82103
Nice one Pogie, I'll remember that bit of info. Can't figure out why the jump part of the function isn't responding when the collide part is, as the engine should be pausing whilst waiting for the right combination of get keys. The only thing I can suggest is making the collider a bit longer, but not long enough for Dizzy to hang below the whip. Sorry.
👍 0
#82104

I've had a little play around with this and may have found a solution Pogie. However, it will involve a bit of trial and error to find the correct 'position'.

After setting the idx to the collider id and before setting the P_TILE, you can do a check that ensures that Dizzy is high enough for the jump action to work otherwise he just drops off the whip.

if (PlayerGet(P_Y)>90) //or whatever number fits
{
ObjSet(idx, O_DISABLE, 1);
WaitFrames(40);
ObjSet(idx, O_DISABLE, 0);
return;
}

Note that it is a 'greater than' check, so you'll have to reduce the number by approx 4 each time. Perhaps a good starting position is with only his feet below the bottom of the whip. I'll keep my fingers crossed!

👍 0
#82108
Thanks Grandad, I've fiddled and fiddled and I think I've got the size of the collider and the disabling coordinate just about right. I've tested it over and over jumping from every position I can and Dizzy doesn't seem to ever get "stuck" hanging in mid-air now. Hopefully there's nothing else here that needs fixing! Good work Grandad :yes:
👍 0