⌂ YolkfolkThe Dizzy Fansite
Community discussion

Running

Started by Grandad on 26 February 2011 • 4,376 views

9 posts
#54904

I've got to the point in my new game where I want to include Jamie's coding on running when holding down the control key, but I'm not sure if it's going to conflict with Colin's coding I use for climbing.

To save looking it up Jamie says that first you amend the HandlerPlayerUpdate in the handlers.gs file to:

// Custom movement test
PlayerSet (P_CUSTOMMOVE, 1);
CM_Update();

then add

Test_Ctrl();

to the start of the function CM_EnterKeyState() in movement.gs file.

Then add the following code to the bottom of movement.gs:

//////////////////////////////////
// tests if CTRL is being pressed (to walk fast)
/////////////////////////////////
func Test_Ctrl()
{
     if (KeyboardStatus (0x1D) || KeyboardStatus (0x9D || JoystickStatus(3))
     { CM_STEPX=8; } //set walk speed to double
     else { CM_STEPX=4; } // set walk speed to normal
}

For Colin's climbing code you add the Movement.2 file, which updates key states and starts:

#def CM2_STEPX		4 // move step x
#def CM2_STEPY		2 // move step y; used in adjustments
#def CM2_STEPYMAX	4 // move step y; used in jumps and falls
#def CM2_BOXW		8 // collision box width
#def CM2_BOXH		8 // collision box height

Also, the HandlerPlayerUpdate code in handlers.gs is changed to:

// Custom movement test
	custommove = PlayerGet (P_CUSTOMMOVE);
	if (custommove == 0) //engine default
	{
	PlayerSet(P_W, CM_BOXW);
	PlayerSet(P_H, CM_BOXH);
	}

	else
	if (custommove == 1) //scripted default
	{
	CM2_Update();
	}

which I think would conflict with Jamies code in that script. Then of course the function in the game.gs file for climbing uses custom movement:

func LadderCollide()
{
	PlayerSet (P_Y, PlayerGet (P_Y) -2);
	PlayerSet(P_X, laddx);
	if (PlayerGet (P_CUSTOMMOVE) == 0)
	{
	PlayerEnterScripted();
	}

	PlayerSet(P_TILE, 26);
	scub = InventoryHasItem (ID_SCUBA);
	if (scub == 1)
	{
	PlayerSet (P_TILE, 56);
	}

	WaitFrames (6);
	PlayerSet (P_CUSTOMMOVE, 1);
	CM2_EnterIdle();
}

So, I'm not really sure how to deal with this as I think it involves having to check for more than one custom move. Also, I would like the 'running' ability to only be available for a certain part of the game which hopefully could be turned off and on by a status check on a particular dynamic object.

Help please.

Grandad

👍 0
#73394

hmm you're right, it would conflict. I'll have a look to see if something can be worked...

Right, I've had a quick look, and it seems to me that you just need to change the Custom movement test bit of function HandlerPlayerUpdate() in handlers.gs:

// Custom movement test
	custommove = PlayerGet (P_CUSTOMMOVE);
	if (custommove == 0) //engine default
	{
		PlayerSet(P_W, CM_BOXW);
		PlayerSet(P_H, CM_BOXH);
	}
	else
	if (custommove == 1) //activate climbing code
	{
		CM2_Update();
	}
	else
	if (custommove == 2) //activate running code
	{
		CM_Update();
	}

turn the running code on with this line of code:

PlayerSet (P_CUSTOMMOVE, 2);

and turn it off with this:

PlayerSet (P_CUSTOMMOVE, 0);

as far as I can see, that should work. :smile:

👍 0
#73396
Thanks Jamie, I'll have a play around with this just to make sure the basics work ...then I can add the nasty bits! {eggs2}:denzil:
👍 0
#73397
Sorry Jamie, but it doesn't work. The climbing still works fine, but pressing 'control' regardless of whether the function has been turned on or not just causes the player to freeze until you release the 'control' button.

Err, it is 0x1D and not Ox1D isn't it?
👍 0
#73398
try turning dev mode off before testing! :tongue:

Not sure if you realise that when you have dev mode on, you can 'move' dizzy between rooms by moving him while CTRL is held down, and in smaller steps by moving him while SHIFT is held down.
👍 0
#73399
Ah, was just going to mention that, as the 'map' has a few rooms all looking the same and was skipping screens, not freezing!

Turned dev mode off ...and working perfectly (as is the climbing)

Thanks a lot, I shall now have fun with this function!
👍 0
#73426
As usual I feel bound to warn about using the keyboard in DizzyAGE games because it'll pose a significant issue when porting on mobile devices or platforms with no keyboard.

Now one or two little keys aren't that bad, but each game will require a special settings for associating such keys (not to mention a touch screen device).

Consider that DizzyAGE games are also playable with a joystick. So it's best to include all the input functionality with this too. Also the joystick is probably easier to map on a mobile device and it's "native" on platforms.

Use JoystickStatus and JoystickAxe to read the joystick and make sure you test it. Joystick buttons mapping is configurable from dizzy.ini so I recommend to have any more buttons configurable in there too.

------

Or you could activate the running option if the left or right action happens for more than 1 or 3 seconds...

Alex
👍 0
#73435
Alex, I assumed that Jamie had covered that with his test control function as it includes the mapping for both the control buttons on a keyboard and for joystick button '3' which is a default setting in the config file. I assume Colin also covered this as his climbing code has been around for a while now, especially as they are both well versed in coding techniques.
👍 0
#73444
The climbing is fine, as both up and down are already mapped to joystick.

I *think* the running is also mapped to joystick. Can't check as I'm on my phone here (down in london for a few days - see what dedication I give! :tongue: )
👍 0