0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Tile-by-Tile questions
#256780
03/18/09 23:46
03/18/09 23:46
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
ok.. the tile-by-tile editor.. My problem is, that the cursor-block isn´t shown at the cursor position. See Screen: http://daten.rmxpworld.de/shot_0.jpgThe block-model has to be on the position of the red cursor square... Here´s the code i use at the moment ( based on an idea by flits ):
function editor_raster_scale(var* pos,var tile_size)
{
// ->scale to raster
if(abs(fraction(pos[0]/tile_size)) > 0.5)
{pos[0] += (tile_size/2)*sign(pos[0]);}
if(abs(fraction(pos[1]/tile_size)) > 0.5)
{pos[1] += (tile_size/2)*sign(pos[1]);}
pos[0] = pos[0] * 1/tile_size;
pos[1] = pos[1] * 1/tile_size;
pos[0] = integer(pos[0]);
pos[1] = integer(pos[1]);
pos[0] = pos[0] * tile_size;
pos[1] = pos[1] * tile_size;
Feldhelper.x = pos[0];
Feldhelper.y = pos[1]+128;
}
function mouse_controll()
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = camera.z;
vec_for_screen(temp,camera);
c_trace(camera,vector(temp.x,temp.y,-4000),IGNORE_ME | IGNORE_PASSABLE);
editor_raster_scale(temp.x,32);
}
Feldhelper is the block-entity Hope someone has an idea...
|
|
|
Re: Tile-by-Tile questions
[Re: Espér]
#257117
03/20/09 15:13
03/20/09 15:13
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I recently had a problem like this, the cursor moves away from the mouse position badly if you rotate the camera? Try this instead. Could be badly wrong though. function mouse_controll()
{
temp.x = mouse_cursor.x;
temp.y = mouse_cursor.y;
temp.z = camera.z;
rel_for_screen(temp,camera);
c_trace(camera,vector(temp.x,temp.y,-4000),IGNORE_ME | IGNORE_PASSABLE);
editor_raster_scale(temp.x,32);
}
I'll have a closer look later... Any chance of getting the complete code (with models)?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tile-by-Tile questions
[Re: EvilSOB]
#257140
03/20/09 18:13
03/20/09 18:13
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
hmm.. not really helpful.. is not working ^^ uhm.. here´s the complete ( new ) mainscript:
//================================================================================================================================//
// //
// • Game_Main //
// //
//================================================================================================================================//
// Das Main Script regelt alle Startaktionen/Eingebundenen Scripts und Debugging Aktionen des Spiels //
//================================================================================================================================//
//================================================================================================================================//
//================================================================================================================================//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// •• Includings //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define PRAGMA_PATH "Modelle"
#define PRAGMA_PATH "Modelle/Editor/"
#define PRAGMA_PATH "Grafiken"
#define PRAGMA_PATH "Grafiken/Sky/"
#include "acknex.h"
#include "default.c"
#include "game_variables.c"
#include "game_entities.c"
//================================================================================================================================//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// •• Panels //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PANEL* debug =
{
layer = 999;
digits(10,10,10,*,1,pos[0]);
digits(10,20,10,*,1,pos[1]);
flags = SHOW;
}
//================================================================================================================================//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// •• Aktionen //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
action helper()
{
Feldhelper = my;
my.alpha = 100;
set(my,PASSABLE);
set(my,BRIGHT);
while(1)
{
wait(1);
}
}
//================================================================================================================================//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// •• Funktionen //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function editor_raster_scale(var* pos,var tile_size)
{
// ->scale to raster
if(abs(fraction(pos[0]/tile_size)) > 0.5)
{pos[0] += (tile_size/2)*sign(pos[0]);}
if(abs(fraction(pos[1]/tile_size)) > 0.5)
{pos[1] += (tile_size/2)*sign(pos[1]);}
pos[0] = pos[0] * 1/tile_size;
pos[1] = pos[1] * 1/tile_size;
pos[0] = integer(pos[0]);
pos[1] = integer(pos[1]);
pos[0] = pos[0] * tile_size;
pos[1] = pos[1] * tile_size;
Feldhelper.x = pos[0];
Feldhelper.y = pos[1]-16;
Feldhelper.z = 16;
}
function mouse_controll()
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 1000;
vec_for_screen(temp.x,camera);
c_trace(camera.x,temp.x,IGNORE_ME | IGNORE_PASSABLE);
editor_raster_scale(target.x,32);
}
function cursor()
{
while(1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
if(key_cuu == 1){camera.y += 10*(key_shift*2)*time_step;}
if(key_cud == 1){camera.y -= 10*(key_shift*2)*time_step;}
if(key_cul == 1){camera.x -= 10*(key_shift*2)*time_step;}
if(key_cur == 1){camera.y += 10*(key_shift*2)*time_step;}
wait(1);
}
}
//================================================================================================================================//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// •• Die Main Funktion //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function main()
{
fps_max = 60;
video_set(1024,768,32,0);
video_window(NULL,NULL,16,"Spirit of the Darkness");
level_load(NULL);
draw_begin();
ent_createlayer("Sky_1+6.bmp", SKY | CUBE | SHOW, 0);
sky_color.red = 1;
sky_color.green = 1;
sky_color.blue = 1;
Feldraster = ent_create("Editor_Raster+1.tga",vector(16,0,0),NULL);
Feldraster.tilt = 90;
reset(Feldraster,PASSABLE);
wait(1);
c_setminmax(Feldraster);
wait(1);
vec_set(Feldraster.min_x,vector(Feldraster.min_x,Feldraster.min_y,-10));
vec_set(Feldraster.max_x,vector(Feldraster.max_x,Feldraster.max_y,-1));
wait(3);
camera.pan = 90;
camera.tilt = -45;
camera.roll = 0;
camera.x = 0;
camera.y = -600;
camera.z = 600;
mouse_mode = 2;
mouse_map = bmap_create("cursor.png");
mouse_range = 18000;
ent_create("Helper.mdl",vector(0,0,8),helper);
cursor();
while(1)
{
mouse_controll();
wait(1);
}
}
and her a video of the problem: http://daten.rmxpworld.de/Phase___001.wmv
|
|
|
Re: Tile-by-Tile questions
[Re: Espér]
#257232
03/21/09 17:28
03/21/09 17:28
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
This looks good to me, assuming I fabricated your models/images correctly. ( mouse_controll function only place changes made) function mouse_controll()
{
VECTOR tmpV0, tmpV1, tmpV2;
vec_set(tmpV1, vector(mouse_cursor.x,mouse_cursor.y, 1)); vec_for_screen(tmpV1,camera);
vec_set(tmpV2, vector(mouse_cursor.x,mouse_cursor.y,1000)); vec_for_screen(tmpV2,camera);
if(tmpV1.z!=tmpV2.z) //you can skip this check if camera roll is ALWAYS 0 and tilt is NEVER 0 or 180
{
vec_lerp(tmpV0, tmpV1, tmpV2, (16-tmpV1.z)/(tmpV2.z - tmpV1.z));
editor_raster_scale(tmpV0, 32);
}
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tile-by-Tile questions
[Re: EvilSOB]
#257248
03/21/09 22:18
03/21/09 22:18
|
Joined: Apr 2007
Posts: 582 Germany
Poison
User
|
User
Joined: Apr 2007
Posts: 582
Germany
|
this should work(not tested):
function mouse_trace()
{
vec_set(mouse_from.x,mouse_cursor.x);
vec_set(mouse_to.x,mouse_from.x);
mouse_to.z = 4000;
vec_for_screen(mouse_from.x,camera);
vec_for_screen(mouse_to.x,camera);
editor_raster_scale(mouse_to.x,32);
c_trace(mouse_from.x,mouse_to.x,IGNORE_ME | IGNORE_PASSABLE);
}
Everything is possible, just Do it!
|
|
|
|