Jump to content


Dash the Ultimate Warrior

Member Since 23 Feb 2007
Offline Last Active Sep 06 2009 02:48 AM

Posts I've Made

In Topic: Weird Problems Occur When Running/jumping

03 September 2009 - 07:50 PM

Can i see every code you have for your character?


Hmm...okay. It'll take up a lot of space, but here goes:

Create event
aimdir = 4; // The direction the player is aiming (8 possible direction)
movespeed = 4; // The speed at which the player runs
shooting=0
shootspeed = 8;
//c_shot = obj_p12_blt;
can_move = true;
can_shoot = true;
airborne = true;
image_speed = 0.08

Step event
// Gravity code (geez this gets tricky)

if (place_free(x, y + 1))
{
	gravity = 0.5;
	can_shoot = false;
	airborne = true;
	
	// Sprite check (jump)
	if aimdir = 3 or aimdir = 4 or aimdir = 5
	{
		sprite_index = spr_p1_jump_R;
	} else {
		sprite_index = spr_p1_jump_L;
	}
		
} else {
	gravity = 0;
	can_shoot = true;
	airborne = false;
	
	// Sprite check (idle)
	if aimdir = 3 or aimdir = 4 or aimdir = 5
	{
		sprite_index = spr_p1_idle_R;
	} else {
		sprite_index = spr_p1_idle_L;
	}
}

// Direction check (tedious I know)

if keyboard_check(vk_left)
{
	switch 1
	{
		case keyboard_check(vk_up):  aimdir=1; break;
		case keyboard_check(vk_down):  aimdir=7; break;
		default:	aimdir=0; break;
	}
}
else
if keyboard_check(vk_right)
{
	switch 1
	{
		case keyboard_check(vk_up):  aimdir=3; break;
		case keyboard_check(vk_down):  aimdir=5; break;
		default:	aimdir=4; break;
	}
}
else
if keyboard_check(vk_up)
{
	aimdir = 2;
}
else
if keyboard_check(vk_down)
{
	aimdir = 6;
}

// Moving stuff

if (keyboard_check(vk_left) and can_move = true)
{
	image_speed = 0.3;
	if aimdir>=2 and aimdir<=5 and airborne = false aimdir = 0;
	sprite_index = spr_p1_run_L;
	x -= movespeed;
}
else
if (keyboard_check(vk_right) and can_move = true)
{
	image_speed = 0.3;
	if aimdir<2 or aimdir>5 and airborne = false aimdir = 4;
	sprite_index = spr_p1_run_R;
	x += movespeed;
}

// Idle
if (keyboard_check(vk_nokey)) and shooting=0
{
	can_move = true;
	image_speed = 0.08;
	
	//Left
	if (aimdir<2 or aimdir>5 )
	{
		sprite_index = spr_p1_idle_L;
	}
	
	//Right
	if (aimdir>=2 and aimdir<=5)
	{
		sprite_index = spr_p1_idle_R;
	}
}

// Sprite switch
if place_free(x-4,y) and keyboard_check(vk_left)
{
x-=4
	if !place_free(x,y+1)
	{
	sprite_index = spr_p1_run_L;
	}
	else
	{
	sprite_index = spr_p1_jump_L;
	}
}

if place_free(x+4,y) and keyboard_check(vk_right)
{
x-=4
	if !place_free(x,y+1)
	{
	sprite_index = spr_p1_run_R;
	}
	else
	{
	sprite_index = spr_p1_jump_R;
	}

Collision w/ obj_parent_floor
if (vspeed > 0 && !place_free(x, y + vspeed))
{
move_contact_solid(270, 4);
}
vspeed = 0;

Press 'S' key
if !place_free(x,y+1)
{
vspeed = -5;
}

In Topic: Weird Problems Occur When Running/jumping

02 September 2009 - 02:10 AM

You were helpful, I don't know how yet because I'm confused with your advice.

I pasted the code after all the other code in the step event, and now he won't even move! I probably did something wrong. Did I?

In Topic: Trouble With Shooting Animation

09 April 2009 - 11:57 PM

Well at a closer look in the code, you shouldn't be moving at all when the key is down, and you shouldn't fire either... All I could think of is changing the else to an explicit false, but that shouldn't do anything. Maybe you could post the file?


http://www.dashproject.com/

My (in-development) website. The link to the GMK is on the front page, in the updates entry for April 9th, 2009.

In Topic: Trouble With Shooting Animation

09 April 2009 - 10:09 PM

Try using

//Check for key press
if (keyboard_check_press(word('S')))
{
See, the way that you have it set up now is to check for the key is pressed. So, it keeps running because the key is still being pressed. The above code, however, checks to see if the key is being pressed at the time of the check. As a step event runs fast enough that it would always be caught, but only once per press, it should only perform once.


tried it, but the animation is too fast (it only goes to the shooting animation for the first frame, due to the key press only working for one step each time.) I need him to stop, cycle through all frames of his shooting animation while firing a single shot, then continue moving.

In Topic: Trouble With Shooting Animation

09 April 2009 - 10:05 PM

//Check for key press
if (keyboard_check(word('S')))
{

does that work?


No, afraid not...that's exactly what I put up there though. And it's "ord" not "word." Thank you for your help though :D but I really need to get the game engine done by mid-May! So I'm stressed n stuff.