eastern-flames/eastern flames/scripts/st_moving/st_moving.gml

68 lines
1.4 KiB
Plaintext
Raw Normal View History

2022-08-15 04:06:41 +00:00
function st_moving() {
var mov = 2
c_input();
hspd = lerp(hspd, (right-left)*.05, .4);
vspd = lerp(vspd, (down-up)*.05, .4);
var remainingmov = mov+1 - (
abs(x+hspd-16-pos.x*ts.x)/ts.x +
abs(y+vspd-16-pos.y*ts.y)/ts.y
);
//var shitmode = point_distance(x, y, pos.x*ts.x, pos.y*ts.y);
//if shitmode > mov*ts.x {
x += hspd*ts.x;
y += vspd*ts.y;
while !remainingmov {
hspd = 0;
vspd = 0;
x = linear_approach(x, pos.x*ts.x+16, 1);
y = linear_approach(y, pos.y*ts.y+16, 1);
log(x, pos.x*ts.x);
log(y, pos.y*ts.y);
var remainingmov = mov+1 - (
abs(x+hspd-16-pos.x*ts.x)/ts.x +
abs(y+vspd-16-pos.y*ts.y)/ts.y
);
//log("oob, " + string(remainingmov));
/*} else {
log("not oob!");*/
}
prevremainingmov = remainingmov;
/*if x < (pos.x-mov)*ts.x {
x = (pos.x-mov)*ts.x;
} else if x > (pos.x+mov+1)*ts.x {
x = (pos.x+mov+1)*ts.x;
} else {
x += hspd*ts.x;
}
if y < (pos.y-mov)*ts.y {
y = (pos.y-mov)*ts.y;
} else if y > (pos.y+mov+1)*ts.y {
y = (pos.y+mov+1)*ts.y;
} else {
y += vspd*ts.y;
}*/
}
function st_movingdraw() {
/*var mov = 2;
draw_set_color(c_cyan);
draw_set_alpha(.4);
var i, j;
for (i=-mov; i<=mov; i++) {
for (j=-mov; j<=mov; j++) {
if abs(i)+abs(j) <= mov {
draw_rectangle(
(pos.x+i)*ts.x,
(pos.y+j)*ts.y,
(pos.x+i+1)*ts.x,
(pos.y+j+1)*ts.y, false
);
}
}
}
draw_set_alpha(1);*/
}
#macro ts global.tilesize