camera schmoovin

This commit is contained in:
the me 2022-08-17 09:49:45 -07:00
parent bc06894859
commit 1e6aa9f530
12 changed files with 36 additions and 34 deletions

View file

@ -1,4 +1,5 @@
c_addunit(un.chara, ARMY.US);
c_addunit(un.kris, ARMY.THEM);
var i;
/*for (i=0; i<array_length(global.units[ARMY.US]); i++) {
c_inheritunit(2+i, 2, un.chara);
@ -10,6 +11,8 @@ var kris = c_inheritunit(10, 5, un.kris);
c_addweapon(kris, wp[$"iron sword"], true);
selectedunit = noone;
hoveredunit = noone;
hspd = 0;
vspd = 0;
global.gw = 640;
global.gh = 360;
global.camerax = 0;

View file

@ -27,7 +27,21 @@ if select && selectedunit == noone {
//draw_text(global.gw-10, global.gh-10-i*20;
}
}
if selectedunit == noone {
hspd = lerp(hspd, (right-left)*((.1+stop*.1)*(ts.x)), .4);
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);
}
global.camerax = x;
global.cameray = y;
var mousex = floor(mouse.x/global.tilesize.x);
var mousey = floor(mouse.y/global.tilesize.y);
//log(mousex, mousey);
@ -42,15 +56,3 @@ if mousex < array_length(global.map) && mousex >= 0 {
}
}
}
if(left){
global.camerax--;
}
if(right){
global.camerax++;
}
if(up){
global.cameray--;
}
if(down){
global.cameray++;
}