|
1 registered members (AndrewAMD),
599
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: Espér]
#236977
11/17/08 13:57
11/17/08 13:57
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
User
|
User
Joined: Oct 2008
Posts: 513
|
Ok the idea is to create one big and oriented bitmap that covers the whole map at the height of my blocks. I will erase parts of the bitmap depending on what squares should be visible, and create floor/wall tiles under the parts that I erase of the bitmap. That way I dont create tons of entities on game start, I only create them when they are visible, and and erase squares of the bitmap at the positions that are now visible. I am trying to do this based on "fog of war" code that does something similar but erases circles. The code is not mine, it is extracted form the CC turorial, I am just trying to modify it for what I need to do. action fog_war_spr {
my.passable = on;
my.overlay = on;
my.oriented = on;
my.tilt = 90;
fog_war = my;
fog_war_map = bmap_for_entity(my,0);
}
action soldier {
my.mode = mode_stand;
my.speed = 6;
my.agility = 40;
my.team = 1;
my.sight_dist = 200;
my.anim_index = random(100); //randomize animation a little
you = ent_create(select_ring_spr,my.x,select_ring);
you.parent_handle = handle(me);
you = ent_create(hbar_back_spr,my.x,hbar_back);
you.parent_handle = handle(me);
my.enable_scan = on;
my.enable_Detect = on;
my.event = soldier_scan_Event;
while(1) {
if(my.mode == mode_stand) { //stand
my.anim_index += time;
my.fog_scan -= 0.1 * time;
ent_Animate(my,"stand",my.anim_index,anm_cycle);
}
if(my.mode == mode_move) { //move to location stored in my.target_x
my.force_x = my.speed * time;
vec_diff(temp,my.target_x,my.x);
vec_to_angle(my.ang_pan,temp);
temp_ang.pan = ang(my.ang_pan - my.pan);
if(temp_ang.pan > 0) { my.pan += min(my.agility * time,abs(temp_ang.pan)); }
if(temp_ang.pan < 0) { my.pan -= min(my.agility * time,abs(temp_ang.pan)); }
my.anim_index += 5 * time;
ent_animate(my,"run",my.anim_index,anm_cycle);
my.unit_scan -= time;
if(my.unit_scan <= 0) {
my.unit_scan = unit_scan_time;
vec_set(temp,vector(360,360,100));
you = null;
scan_entity(my.x,temp);
}
move_friction = 0;
move_mode = ignore_passable + glide;
ent_move(my.force_x,nullvector);
if(vec_dist(my.target_x,my.x) < 40) { //close enough to destination -> stop moving
my.mode = mode_stand;
my.anim_index = 0;
}
}
if(my.selected == on && dest_set) {
vec_Set(my.target_X,dest_pos);
my.mode = mode_move;
if(my.mode != mode_move) {my.anim_index = 0;}
}
if(left_pressed) {my.selected = off;}
if(fog_war_map != null && fog_war != null && my.fog_scan <= 0) {
vec_set(clearfog,my.x);
clearfog.x *= -(1/fog_war.scale_X); //invert x coord
clearfog.y *= (1/fog_war.scale_y);
vec_add(clearfog,vector(500,500,0));
clearfog.z = 0;
temp_format = bmap_lock(fog_war_map,0);
temp_pixel = pixel_for_vec(vector(0,0,0),0,temp_format);
clear_circle(clearfog,my.sight_dist,temp_pixel);
bmap_unlock(fog_war_map);
my.fog_scan = fog_scan_Time;
}
if(my.mode != mode_Stand) {my.fog_scan -= time;}
wait(1);
}
}
function clear_circle(¢er,rad,pixel) { //clear out a circle of fog_war_map
var p[3];
var cen[3];
vec_set(cen,center);
var bound1[3];
var bound2[3];
rad *= 1/fog_war.scale_X;
vec_set(bound1,vector(cen.x - rad,cen.y - rad,0));
vec_set(bound2,vector(cen.x + rad,cen.y + rad,0));
vec_set(p,bound1);
while(p.y <= bound2.y) {
p.x = bound1.x;
while(p.x <= bound2.x) {
if(vec_dist(p,cen) <= rad) {
pixel_to_bmap(fog_war_map,p.x,p.y,pixel);
}
p.x += 1;
}
p.y += 1;
}
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: Espér]
#237197
11/18/08 20:40
11/18/08 20:40
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Beware reaper, In the long run, by the end of the level, a great many,if not all, of the entity-blocks will be visible. So the level will get laggier the more of it is discovered, unless you fog-of-war hide the blocks that are most distant from the camera. But try anyway, it may be usable, it IS a good idea, but I never tried it because I thought what I just said above was enevitable. But Ive been wrong before. 
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: EvilSOB]
#237210
11/18/08 23:06
11/18/08 23:06
|
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
|
Got a way:
The not diggable blocks are ONE Block-Model, with a hole of the diggables inside. So i just have to view the blocks, the player is able to destroy.
Un-diggables = 1 Model Floor = 1 Model Water and Lava = 1 Model
And not the complete Map is filled with blocks. There will be pre-defined watertunnels ( like in the original dungeon keeper ). And those tunnels are not closed ^^
That should make that thing more faster.
Last edited by xXReapeRXx; 11/18/08 23:13.
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: Espér]
#237216
11/19/08 00:17
11/19/08 00:17
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Oh yeah, good thought.
Keep me informed on how its going as you get places.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: EvilSOB]
#237218
11/19/08 00:23
11/19/08 00:23
|
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
|
Yeah i will do...
XD.. it scares me if i think of the upcoming problems: - Pathfinding - Watershader - Particle Effects - Over-earth missions ( building walls/hedges instead of digging the earth ) - Battle and Social AI
*groans*
First i can say: On a 50x50 Map, loading time is under 10 seconds. FPS are 55+ ( 60 max )
Last edited by xXReapeRXx; 11/19/08 00:23.
|
|
|
Re: Destroy a block-model && Cam rotation around a fix point
[Re: Espér]
#237222
11/19/08 01:05
11/19/08 01:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Hehehe, sound like fun.... heres some suggestions - Pathfinding = steal other peoples work  - Watershader = acknex unlimited site / demos / "water shader added" - Particle Effects = acknex unlimited site / tutorials / "Advanced particle effects" - Over-earth missions ( building walls/hedges instead of digging the earth ) = start with the level "all dug out", with un-movable hedges as a border. Un-Dig to build the hedges. - Battle and Social AI = no idea, depends on its actual needs.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|