im schmoovin, slightly more

This commit is contained in:
the me 2022-08-19 15:06:21 -07:00
parent f53d693a0c
commit e6fc2dcf96
21 changed files with 689 additions and 31 deletions

View file

@ -1,7 +1,7 @@
function st_control() {
c_input();
var mouse = c_2dto3d(mouse_x,mouse_y);
if select && selectedunit == noone {
if select {
var mousex = floor(mouse.x/global.tilesize.x);
var mousey = floor(mouse.y/global.tilesize.y);
log(mousex, mousey);
@ -12,7 +12,7 @@ function st_control() {
if global.map[mousex][mousey].contents[i].object_index == o_unit {
var dude = global.map[mousex][mousey].contents[i];
if dude.alignment == global.turn {
c_selectunit(dude);
if selectedunit == noone c_selectunit(dude);
} else {
c_markunit(dude);
}
@ -37,14 +37,16 @@ function st_control() {
vspd = lerp(vspd, (down-up)*((.1+stop*.1)*(ts.y)), .4);
x += hspd;
y += vspd;
} else {
hspd = 0;
vspd = 0;
x = lerp(x, selectedunit.x, .4);
y = lerp(y, selectedunit.y, .4);
//cursor.x = selectedunit.x;
//cursor.y = selectedunit.y;
}
cursor.x = mouse_x;
cursor.y = mouse_y;
global.camerax = x;
global.cameray = y;
var mousex = floor(mouse.x/global.tilesize.x);
@ -61,7 +63,10 @@ function st_control() {
}
}
}
if hoveredunit != noone {
//cursor.x = lerp(mouse_x, hoveredunit.x, .4);
//cursor.y = lerp(mouse_y, hoveredunit.y, .4);
}
var i;
for (i=0; i<array_length(global.units[global.turn]); i++) {
if global.units[global.turn][i].waiting = false exit;

View file

@ -12,35 +12,53 @@ function st_moving() {
if downp dir = DIR.DOWN;
if upp dir = DIR.UP;
if rightp dir = DIR.RIGHT;
var remainingmov = mov+1 - (
/*var remainingmov = mov+1 - (
abs(x+hspd-16-returnpos.x*ts.x)/ts.x +
abs(y+vspd-16-returnpos.y*ts.y)/ts.y
);
);*/
var dist = c_tiledist(pos.x, pos.y, returnpos.y, returnpos.y);
//var remainingmov = dist.x + dist.y;
//var shitmode = point_distance(x, y, returnpos.x*ts.x, returnpos.y*ts.y);
//if shitmode > mov*ts.x {
if !stop {
x += hspd*ts.x;
y += vspd*ts.y;
}
while !remainingmov {
hspd = 0;
//while !remainingmov {
/*hspd = 0;
vspd = 0;
x = linear_approach(x, returnpos.x*ts.x+16, 1);
y = linear_approach(y, returnpos.y*ts.y+16, 1);
x = linear_approach(x, returnpos.x*ts.x, 1);
y = linear_approach(y, returnpos.y*ts.y, 1);
log(x, returnpos.x*ts.x);
log(y, returnpos.y*ts.y);
var remainingmov = mov+1 - (
abs(x+hspd-16-returnpos.x*ts.x)/ts.x +
abs(y+vspd-16-returnpos.y*ts.y)/ts.y
);
);*/
//log("oob, " + string(remainingmov));
/*} else {
log("not oob!");*/
//}
var dude = c_gettile(x+hspd+abs(sprite_width)/4, y+vspd, true);
if dude != noone {
var dist = c_tiledist(dude.x, dude.y, returnpos.x, returnpos.y);
if dist.x + dist.y <= data.mov.val && dude.passable {
pos.x = dude.x;
pos.y = dude.y;
if !stop {
x += hspd*ts.x;
y += vspd*ts.y;
}
} else {
x -= hspd*ts.x;
y -= vspd*ts.y;
x = linear_approach(x, returnpos.x*ts.x+abs(sprite_width)/4, 1);
y = linear_approach(y, returnpos.y*ts.y, 1);
}
} else {
x -= hspd*ts.x;
y -= vspd*ts.y;
x = linear_approach(x, returnpos.x*ts.x+abs(sprite_width)/4, 1);
y = linear_approach(y, returnpos.y*ts.y, 1);
}
var dude = c_gettile(x, y, true);
pos.x = dude.x;
pos.y = dude.y;
prevremainingmov = remainingmov;
//prevremainingmov = remainingmov;
c_decolor_all(c_red);
c_decolor_all(c_green);
var guy = c_gettile(pos.x, pos.y);
@ -97,7 +115,7 @@ function st_moving() {
c_moveunit(id, c_gettile(returnpos.x, returnpos.y));
c_deselectunit(id);
}
if dir == DIR.NONE && select {
if dir == DIR.NONE && select && stop && ARTICULATOR.hoveredunit == id{
c_moveunit(id, c_gettile(x, y, true));
waiting = true;
c_deselectunit(id);

View file

@ -1,5 +1,5 @@
var forest123456 = function() {return new tiledata(u, u, [c_lime], [new statmod(st.def, 5, add)])}
var block1234567 = function() {return new tiledata(false, u, [c_black])}
var forest123456 = function() {return new tiledata(u, u, [], [new statmod(st.def, 5, add)])}
var block1234567 = function() {return new tiledata(false, u, [])}
global.map = c_mapgen([
[block1234567(), block1234567(), block1234567(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), block1234567(), block1234567(), block1234567(), block1234567(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata()],
[block1234567(), block1234567(), block1234567(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), forest123456(), new tiledata(), new tiledata(), block1234567(), block1234567(), block1234567(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata()],