Q
qbot21
Guest
Hello
Im working on TDS prototype with a bit tactical approach. What I want to achieve, is that Player's speed is reduced, when he is moving backwards and making sidesteps depending on direction he is facing. Sadly I cannot solve it by myself. Im using point_direction to allow mouse aim.
Code:
Im working on TDS prototype with a bit tactical approach. What I want to achieve, is that Player's speed is reduced, when he is moving backwards and making sidesteps depending on direction he is facing. Sadly I cannot solve it by myself. Im using point_direction to allow mouse aim.
Code:
Code:
// Step
var sec = delta_time/1000000;
var move_speed = floor(spd*sec);
var move_xinput = 0;
var move_yinput = 0;
direction = point_direction(x, y, mouse_x, mouse_y);
image_angle = direction;
for ( var i = 0; i < array_length_1d(movement_inputs); i++){
var this_key = movement_inputs[i];
if keyboard_check(this_key) {
var this_angle = i*90;
move_xinput += lengthdir_x(1, this_angle);
move_yinput += lengthdir_y(1, this_angle);
}
}
var moving = ( point_distance(0,0,move_xinput,move_yinput) > 0 );
if moving {
var move_dir = point_direction(0,0,move_xinput,move_yinput);
move(move_speed, move_dir);
}
switch (state){
case states.moving:
spd = 180;
if keyboard_check(run){
state = states.run;
}
else if mouse_check_button(aim){
state = states.aim;
}
break;
case states.run:
is_running = true;
spd = 300;
if !keyboard_check(run){
state = states.moving;
is_running = false;
}
break;
case states.aim:
is_aiming = true;
spd = 70;
if !mouse_check_button(aim){
state = states.moving;
is_aiming = false;
}
break;
}
show_debug_message(move_speed);
Code:
// move script
var spd = argument0;
var dir = argument1;
var xtarg = x+lengthdir_x(spd,dir);
var ytarg = y+lengthdir_y(spd,dir);
if place_free(xtarg,ytarg) {
x = xtarg;
y = ytarg;
}
else {
var sweep_interval = 10;
for ( var angle = sweep_interval; angle <= 80; angle += sweep_interval) {
for ( var multiplier = -1; multiplier <= 1; multiplier += 2) {
var angle_to_check = dir+angle*multiplier;
xtarg = x+lengthdir_x(spd, angle_to_check);
ytarg = y+lengthdir_y(spd, angle_to_check);
if place_free(xtarg,ytarg) {
x = xtarg;
y = ytarg;
exit;
}
}
}
}