THREEDEE
This commit is contained in:
parent
757034f5b5
commit
bc06894859
|
@ -55,6 +55,7 @@
|
||||||
{"id":{"name":"keyboard_check_advanced","path":"scripts/keyboard_check_advanced/keyboard_check_advanced.yy",},"order":8,},
|
{"id":{"name":"keyboard_check_advanced","path":"scripts/keyboard_check_advanced/keyboard_check_advanced.yy",},"order":8,},
|
||||||
{"id":{"name":"collision_line_width","path":"scripts/collision_line_width/collision_line_width.yy",},"order":9,},
|
{"id":{"name":"collision_line_width","path":"scripts/collision_line_width/collision_line_width.yy",},"order":9,},
|
||||||
{"id":{"name":"draw_rectangle_width","path":"scripts/draw_rectangle_width/draw_rectangle_width.yy",},"order":7,},
|
{"id":{"name":"draw_rectangle_width","path":"scripts/draw_rectangle_width/draw_rectangle_width.yy",},"order":7,},
|
||||||
|
{"id":{"name":"c_2dto3d","path":"scripts/c_2dto3d/c_2dto3d.yy",},"order":20,},
|
||||||
{"id":{"name":"s_guy2","path":"sprites/s_guy2/s_guy2.yy",},"order":1,},
|
{"id":{"name":"s_guy2","path":"sprites/s_guy2/s_guy2.yy",},"order":1,},
|
||||||
{"id":{"name":"s_momiji","path":"sprites/s_momiji/s_momiji.yy",},"order":0,},
|
{"id":{"name":"s_momiji","path":"sprites/s_momiji/s_momiji.yy",},"order":0,},
|
||||||
{"id":{"name":"dir2hv","path":"scripts/dir2hv/dir2hv.yy",},"order":2,},
|
{"id":{"name":"dir2hv","path":"scripts/dir2hv/dir2hv.yy",},"order":2,},
|
||||||
|
|
|
@ -12,3 +12,22 @@ selectedunit = noone;
|
||||||
hoveredunit = noone;
|
hoveredunit = noone;
|
||||||
global.gw = 640;
|
global.gw = 640;
|
||||||
global.gh = 360;
|
global.gh = 360;
|
||||||
|
global.camerax = 0;
|
||||||
|
global.cameray = 0;
|
||||||
|
//these are functions bc c_2dto3d uses them
|
||||||
|
function getProj(){
|
||||||
|
return matrix_build_projection_perspective_fov(60,-16/9,1,4000)
|
||||||
|
}
|
||||||
|
function getView(){
|
||||||
|
var _x = global.camerax;
|
||||||
|
var _y = global.cameray;
|
||||||
|
var half = (7.5*32)+40;
|
||||||
|
return matrix_build_lookat(_x,_y+100,100,_x,_y,0,0,0,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCam(){
|
||||||
|
var cam = camera_get_active();
|
||||||
|
camera_set_proj_mat(cam,getProj());
|
||||||
|
camera_set_view_mat(cam,getView())
|
||||||
|
camera_apply(cam);
|
||||||
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
|
||||||
|
var cam = camera_get_active();
|
||||||
|
global.projMat = camera_get_proj_mat(cam);
|
||||||
|
global.viewMat = camera_get_view_mat(cam);
|
||||||
|
setCam();
|
||||||
var i, j, k;
|
var i, j, k;
|
||||||
for (i=0; i<array_length(global.map); i++) {
|
for (i=0; i<array_length(global.map); i++) {
|
||||||
for (j=0; j<array_length(global.map[i]); j++) {
|
for (j=0; j<array_length(global.map[i]); j++) {
|
||||||
|
@ -22,6 +27,7 @@ for (i=0; i<array_length(global.map); i++) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_set_color(c_black);
|
draw_set_color(c_black);
|
||||||
|
|
||||||
var i, j;
|
var i, j;
|
||||||
for (i=0; i<array_length(global.map); i++) {
|
for (i=0; i<array_length(global.map); i++) {
|
||||||
for (j=0; j<array_length(global.map[i]); j++) {
|
for (j=0; j<array_length(global.map[i]); j++) {
|
||||||
|
@ -33,3 +39,7 @@ for (i=0; i<array_length(global.map); i++) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//matrix_get(matrix_
|
||||||
|
|
||||||
|
var a = c_2dto3d(mouse_x,mouse_y);
|
||||||
|
draw_circle(a.x,a.y,2,false);
|
|
@ -1,7 +1,8 @@
|
||||||
c_input();
|
c_input();
|
||||||
|
var mouse = c_2dto3d(mouse_x,mouse_y);
|
||||||
if select && selectedunit == noone {
|
if select && selectedunit == noone {
|
||||||
var mousex = floor(mouse_x/global.tilesize.x);
|
var mousex = floor(mouse.x/global.tilesize.x);
|
||||||
var mousey = floor(mouse_y/global.tilesize.y);
|
var mousey = floor(mouse.y/global.tilesize.y);
|
||||||
log(mousex, mousey);
|
log(mousex, mousey);
|
||||||
if mousex < array_length(global.map) && mousex >= 0 {
|
if mousex < array_length(global.map) && mousex >= 0 {
|
||||||
if mousey < array_length(global.map[mousex]) && mousey >= 0 {
|
if mousey < array_length(global.map[mousex]) && mousey >= 0 {
|
||||||
|
@ -15,8 +16,8 @@ if select && selectedunit == noone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if select {
|
} else if select {
|
||||||
if mouse_x > global.gw-100 {
|
if mouse.x > global.gw-100 {
|
||||||
var guyhits = floor(abs(mouse_y-global.gh-10)/32);
|
var guyhits = floor(abs(mouse.y-global.gh-10)/32);
|
||||||
log(guyhits, array_length(selectedunit.inventory));
|
log(guyhits, array_length(selectedunit.inventory));
|
||||||
if guyhits < array_length(selectedunit.inventory) {
|
if guyhits < array_length(selectedunit.inventory) {
|
||||||
//log("doing");
|
//log("doing");
|
||||||
|
@ -27,8 +28,8 @@ if select && selectedunit == noone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mousex = floor(mouse_x/global.tilesize.x);
|
var mousex = floor(mouse.x/global.tilesize.x);
|
||||||
var mousey = floor(mouse_y/global.tilesize.y);
|
var mousey = floor(mouse.y/global.tilesize.y);
|
||||||
//log(mousex, mousey);
|
//log(mousex, mousey);
|
||||||
hoveredunit = selectedunit;
|
hoveredunit = selectedunit;
|
||||||
if mousex < array_length(global.map) && mousex >= 0 {
|
if mousex < array_length(global.map) && mousex >= 0 {
|
||||||
|
@ -41,3 +42,15 @@ if mousex < array_length(global.map) && mousex >= 0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(left){
|
||||||
|
global.camerax--;
|
||||||
|
}
|
||||||
|
if(right){
|
||||||
|
global.camerax++;
|
||||||
|
}
|
||||||
|
if(up){
|
||||||
|
global.cameray--;
|
||||||
|
}
|
||||||
|
if(down){
|
||||||
|
global.cameray++;
|
||||||
|
}
|
|
@ -1,12 +1,28 @@
|
||||||
|
draw_set_color(c_gray);
|
||||||
|
draw_set_alpha(0.25);
|
||||||
|
draw_circle(x,y+5,10,false);
|
||||||
|
draw_set_alpha(1);
|
||||||
|
var worldMat = matrix_get(matrix_world);
|
||||||
|
//this is the location of where i want to draw from !!!
|
||||||
|
var worldMat2 = matrix_build(x,y,0,90,0,0,1,1,1);
|
||||||
|
matrix_set(matrix_world,worldMat2);
|
||||||
if waiting image_blend = c_grey else image_blend = c_white;
|
if waiting image_blend = c_grey else image_blend = c_white;
|
||||||
|
var tempx = x;
|
||||||
|
var tempy = y;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
draw_self();
|
draw_self();
|
||||||
drawstate();
|
drawstate();
|
||||||
|
x = tempx;
|
||||||
|
y = tempy;
|
||||||
//log(data);
|
//log(data);
|
||||||
draw_set_color(c_red);
|
draw_set_color(c_red);
|
||||||
draw_rectangle(x-ts.x/2, y-ts.y/2-1,
|
draw_rectangle(0-ts.x/2, 0-ts.y/2-1,
|
||||||
x-ts.x/2+(ts.x*(data.hp.val/data.hp.cap)),
|
0-ts.x/2+(ts.x*(data.hp.val/data.hp.cap)),
|
||||||
y-ts.y/2+1, false
|
0-ts.y/2+1, false
|
||||||
);
|
);
|
||||||
draw_text(x, y-ts.y, data.hp.val);
|
draw_text(x, y-ts.y, data.hp.val);
|
||||||
//draw_set_color(c_red);
|
//draw_set_color(c_red);
|
||||||
//draw_circle(x, y, 5, false);
|
//draw_circle(x, y, 5, false);
|
||||||
|
|
||||||
|
matrix_set(matrix_world,worldMat);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// Script assets have changed for v2.3.0 see
|
||||||
|
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
|
||||||
|
/// @description convert_2d_to_3d(x, y, view_mat, proj_mat)
|
||||||
|
/// @param x
|
||||||
|
/// @param y
|
||||||
|
/// @param view_mat
|
||||||
|
/// @param proj_mat
|
||||||
|
/*
|
||||||
|
Transforms a 2D coordinate (in window space) to a 3D vector.
|
||||||
|
Returns an array of the following format:
|
||||||
|
[dx, dy, dz, ox, oy, oz]
|
||||||
|
where [dx, dy, dz] is the direction vector and [ox, oy, oz] is the origin of the ray.
|
||||||
|
Works for both orthographic and perspective projections.
|
||||||
|
Script created by TheSnidr
|
||||||
|
(slightly modified by @dragonitespam)
|
||||||
|
*/
|
||||||
|
function c_2dto3d(_x,_y,V = ARTICULATOR.getView(), P = ARTICULATOR.getProj()){
|
||||||
|
var mx = 2 * (_x / window_get_width() - .5) / P[0];
|
||||||
|
var my = 2 * (_y / window_get_height() - .5) / P[5];
|
||||||
|
var camX = - (V[12] * V[0] + V[13] * V[1] + V[14] * V[2]);
|
||||||
|
var camY = - (V[12] * V[4] + V[13] * V[5] + V[14] * V[6]);
|
||||||
|
var camZ = - (V[12] * V[8] + V[13] * V[9] + V[14] * V[10]);
|
||||||
|
var theVar;
|
||||||
|
if (P[15] == 0)
|
||||||
|
{ //This is a perspective projection
|
||||||
|
theVar = [V[2] + mx * V[0] + my * V[1],
|
||||||
|
V[6] + mx * V[4] + my * V[5],
|
||||||
|
V[10] + mx * V[8] + my * V[9],
|
||||||
|
camX,
|
||||||
|
camY,
|
||||||
|
camZ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //This is an ortho projection
|
||||||
|
theVar = [V[2],
|
||||||
|
V[6],
|
||||||
|
V[10],
|
||||||
|
camX + mx * V[0] + my * V[1],
|
||||||
|
camY + mx * V[4] + my * V[5],
|
||||||
|
camZ + mx * V[8] + my * V[9]];
|
||||||
|
}
|
||||||
|
var s2w = theVar;
|
||||||
|
var fx = s2w[0] * s2w[5] / -s2w[2] + s2w[3];
|
||||||
|
var fy = s2w[1] * s2w[5] / -s2w[2] + s2w[4];
|
||||||
|
return {x:fx,y:fy};
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"isDnD": false,
|
||||||
|
"isCompatibility": false,
|
||||||
|
"parent": {
|
||||||
|
"name": "convenience",
|
||||||
|
"path": "folders/Scripts/util/convenience.yy",
|
||||||
|
},
|
||||||
|
"resourceVersion": "1.0",
|
||||||
|
"name": "c_2dto3d",
|
||||||
|
"tags": [],
|
||||||
|
"resourceType": "GMScript",
|
||||||
|
}
|
Loading…
Reference in New Issue