[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src map_placeable_area.h,1.1.2.5,1.1.
From: |
Alexandre Courbot <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src map_placeable_area.h,1.1.2.5,1.1.2.6 map_moving.h,1.1.2.7,1.1.2.8 map_moving.cc,1.1.2.13,1.1.2.14 map_character_with_gfx.cc,1.1.2.10,1.1.2.11 main.cc,1.39.2.22,1.39.2.23 landmap.h,1.24.4.11,1.24.4.12 landmap.cc,1.18.2.12,1.18.2.13 |
Date: |
Tue, 09 Apr 2002 08:29:58 -0400 |
Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv20205/src
Modified Files:
Tag: Branch_road_to_0-4
map_placeable_area.h map_moving.h map_moving.cc
map_character_with_gfx.cc main.cc landmap.h landmap.cc
Log Message:
Improved map object moving and rendering.
Index: map_placeable_area.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/map_placeable_area.h,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -r1.1.2.5 -r1.1.2.6
*** map_placeable_area.h 30 Mar 2002 17:06:25 -0000 1.1.2.5
--- map_placeable_area.h 9 Apr 2002 12:29:55 -0000 1.1.2.6
***************
*** 47,51 ****
}
! bool is_walkable ()
{
return Walkable;
--- 47,51 ----
}
! bool is_walkable () const
{
return Walkable;
***************
*** 57,61 ****
}
! void put(ogzstream & file)
{
Walkable >> file;
--- 57,61 ----
}
! void put(ogzstream & file) const
{
Walkable >> file;
***************
*** 65,68 ****
--- 65,73 ----
{
Walkable << file;
+ }
+
+ bool does_intersect(const mapsquare_walkable_info & mwi, const u_int16 x,
const u_int16 oy) const
+ {
+ return (is_walkable() && mwi.is_walkable());
}
};
Index: map_moving.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/map_moving.h,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -r1.1.2.7 -r1.1.2.8
*** map_moving.h 2 Apr 2002 20:04:17 -0000 1.1.2.7
--- map_moving.h 9 Apr 2002 12:29:55 -0000 1.1.2.8
***************
*** 46,52 ****
u_int16 Lx, Ly;
! static const u_int16 climb_capability = 5;
public:
map_moving (landmap & mymap);
--- 46,53 ----
u_int16 Lx, Ly;
! static const u_int16 Climb_capability = 5;
public:
+ s_int32 zground;
map_moving (landmap & mymap);
***************
*** 67,70 ****
--- 68,76 ----
}
+ u_int16 climb_capability()
+ {
+ return Climb_capability;
+ }
+
u_int16 lx ()
{
***************
*** 92,95 ****
--- 98,103 ----
*/
void update_pos();
+
+ void update_pos2();
bool update();
Index: map_moving.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/map_moving.cc,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -C2 -r1.1.2.13 -r1.1.2.14
*** map_moving.cc 3 Apr 2002 11:54:47 -0000 1.1.2.13
--- map_moving.cc 9 Apr 2002 12:29:55 -0000 1.1.2.14
***************
*** 41,44 ****
--- 41,46 ----
Has_moved = false;
Is_falling = false;
+
+ zground = -100000;
}
***************
*** 67,70 ****
--- 69,265 ----
}
+ void map_moving::update_pos2()
+ {
+ Has_moved = 0;
+
+ u_int16 nX = X;
+ float nfox = fox;
+ u_int16 nY = Y;
+ float nfoy = foy;
+ s_int32 prevz = z();
+
+ // Calculating new X position
+ if (vx ())
+ {
+ Has_moved = 1;
+
+ nfox += vx ();
+
+ while (nfox < 0)
+ {
+ if (nX > 0)
+ {
+ nX--;
+ nfox += mapsquare_size;
+ }
+ else nfox = 0.0;
+ }
+
+ while (nfox >= mapsquare_size)
+ {
+ if (nX < Lx)
+ {
+ nX++;
+ nfox -= mapsquare_size;
+ }
+ else
+ {
+ nX = Lx - 1;
+ nfox = 39;
+ }
+ }
+ if (nX == Lx - 1)
+ {
+ nfox = 0;
+ }
+ }
+
+ // Calculating new Y position
+ if (vy ())
+ {
+ Has_moved = 1;
+
+ nfoy += vy ();
+ while (nfoy < 0)
+ {
+ if (nY > 0)
+ {
+ nfoy += mapsquare_size;
+ nY--;
+ }
+ else nfoy = 0.0;
+ }
+
+ while (nfoy >= mapsquare_size)
+ {
+ if (nY < Ly)
+ {
+ nfoy -= mapsquare_size;
+ nY++;
+ }
+ else
+ {
+ nY = Ly - 1;
+ nfoy = 39;
+ }
+ }
+ if (nY == Ly - 1)
+ {
+ nfoy = 0;
+ }
+ }
+
+ // Calculating new Z position
+ if (vz())
+ {
+ Has_moved = 1;
+
+ foz += vz();
+ while (foz <= -1.0)
+ {
+ Z--;
+ foz += 1.0;
+ }
+ while (foz >= 1.0)
+ {
+ Z++;
+ foz -= 1.0;
+ }
+ }
+
+ // Now checking walkability
+ map_placeable_area * state = current_state();
+
+ u_int16 nbx = 1 + (nfox != 0.0);
+ u_int16 nby = 1 + (nfoy != 0.0);
+
+ u_int16 px = nX - state->base.x();
+ u_int16 py = nY - state->base.y();
+
+ u_int16 j;
+ u_int16 i;
+
+ Is_falling = true;
+ s_int32 nzground = -100000;
+
+ for (j = 0; j < state->area_height(); px -= i, ++j, ++py)
+ {
+ for (i = 0; i < state->area_length(); ++i, ++px)
+ {
+ if (state->get(i, j).is_walkable()) continue;
+
+ for (u_int16 l = 0; l < nby; ++l)
+ for (u_int16 k = 0; k < nbx; ++k)
+ {
+ mapsquare * msqr = Mymap.get(px + k, py + l);
+
+ if (vz() > 0)
+ {
+ for (mapsquare::iterator it = msqr->begin(); it !=
msqr->end(); it++)
+ {
+ s_int32 objz = it->z();
+ if (objz > z() + current_state()->zsize || objz <
prevz + current_state()->zsize) continue;
+
+ if (!it->obj->current_state()->get(px + k -
it->x() + it->obj->current_state()->base.x(),
+ py + l -
it->y() + it->obj->current_state()->base.y())
+ .is_walkable())
+ {
+ set_altitude(objz - (current_state()->zsize +
1));
+ set_vertical_velocity(0.0);
+ break;
+ }
+ }
+ }
+
+ // Check whether we hit the ground or not and calculate
zground.
+ for (mapsquare::iterator it = msqr->begin(); it !=
msqr->end(); it++)
+ {
+ s_int32 objz = it->z() +
it->obj->current_state()->zsize;
+ if (objz > prevz + climb_capability()) continue;
+
+ if (it->obj->current_state()->get(px + k - it->x() +
it->obj->current_state()->base.x(),
+ py + l - it->y() +
it->obj->current_state()->base.y())
+ .is_walkable()) continue;
+
+ if (objz >= nzground) nzground = objz;
+ if (objz < z()) continue;
+
+ set_altitude(objz);
+ Is_falling = false;
+ set_vertical_velocity(0.0);
+ break;
+ }
+
+ }
+
+ for (u_int16 l = 0; l < nby; l++)
+ for (u_int16 k = 0; k < nbx; k++)
+ {
+ mapsquare * msqr = Mymap.get(px + k, py + l);
+ for (mapsquare::iterator it = msqr->begin(); it !=
msqr->end(); ++it)
+ {
+ if (it->obj->current_state()->get(px + k - it->x() +
it->obj->current_state()->base.x(),
+ py + l - it->y() +
it->obj->current_state()->base.y())
+ .is_walkable()) continue;
+
+ if (z() + climb_capability() < it->z() +
it->obj->current_state()->zsize &&
+ z() + state->zsize > it->z())
+ goto rollback;
+ }
+ }
+ }
+ }
+
+ X = nX;
+ fox = nfox;
+ Ox = (u_int16) fox;
+ Y = nY;
+ foy = nfoy;
+ Oy = (u_int16) foy;
+
+ rollback:
+ zground = nzground;
+ }
+
void map_moving::update_pos()
{
***************
*** 133,137 ****
.is_walkable()) continue;
! if (z() + climb_capability < it->z() +
it->obj->current_state()->zsize &&
z() + state->zsize > it->z())
goto ytest;
--- 328,332 ----
.is_walkable()) continue;
! if (z() + climb_capability() < it->z() +
it->obj->current_state()->zsize &&
z() + state->zsize > it->z())
goto ytest;
***************
*** 208,212 ****
.is_walkable()) continue;
! if (z() + climb_capability < it->z() +
it->obj->current_state()->zsize &&
z() + state->zsize > it->z())
goto ztest;
--- 403,407 ----
.is_walkable()) continue;
! if (z() + climb_capability() < it->z() +
it->obj->current_state()->zsize &&
z() + state->zsize > it->z())
goto ztest;
***************
*** 278,282 ****
{
s_int32 objz = it->z() +
it->obj->current_state()->zsize;
! if (objz < z() || objz > prevz +
climb_capability) continue;
if (!it->obj->current_state()->get(px + k -
it->x() + it->obj->current_state()->base.x(),
--- 473,477 ----
{
s_int32 objz = it->z() +
it->obj->current_state()->zsize;
! if (objz < z() || objz > prevz +
climb_capability()) continue;
if (!it->obj->current_state()->get(px + k -
it->x() + it->obj->current_state()->base.x(),
***************
*** 299,303 ****
Mymap.remove(this);
! update_pos();
Mymap.put(this);
--- 494,498 ----
Mymap.remove(this);
! update_pos2();
Mymap.put(this);
Index: map_character_with_gfx.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/map_character_with_gfx.cc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -r1.1.2.10 -r1.1.2.11
*** map_character_with_gfx.cc 2 Apr 2002 20:04:17 -0000 1.1.2.10
--- map_character_with_gfx.cc 9 Apr 2002 12:29:55 -0000 1.1.2.11
***************
*** 241,283 ****
surface * target = NULL)
{
! s_int32 maxheight;
! bool draw_it = false;
!
! map_placeable_area * state = current_state();
!
! for (int j = 0; j < state->area_height(); j++)
! for (int i = 0; i < state->area_length(); i++)
! {
! if (state->get(i, j).is_walkable()) continue;
! u_int16 px = this->x() - state->base.x() + i;
! u_int16 py = this->y() - state->base.y() + j;
!
! u_int16 nbx = 1 + (ox() != 0);
! u_int16 nby = 1 + (oy() != 0);
!
! for (u_int16 l = 0; l < nby; l++)
! for (u_int16 k = 0; k < nbx; k++)
! {
! mapsquare * msqr = Mymap.get(px + k, py + l);
! for (mapsquare::iterator it = msqr->begin(); it !=
msqr->end(); ++it)
! {
! if (it->obj == this) continue;
! if (it->z() + it->obj->current_state()->zsize > z())
continue;
!
! if (!it->obj->current_state()->get(px + k - it->x() +
it->obj->current_state()->base.x(),
! py + l - it->y() +
it->obj->current_state()->base.y())
! .is_walkable())
! {
! if (!draw_it)
! {
! draw_it = true;
! maxheight = it->obj->current_state()->zsize +
it->z();
! }
! else if (maxheight <
it->obj->current_state()->zsize + it->z())
! maxheight = it->obj->current_state()->zsize +
it->z();
! }
! }
! }
! }
! if (draw_it) shadow.draw(x, y + 25 - maxheight, da_opt, target);
}
--- 241,244 ----
surface * target = NULL)
{
! shadow.draw(x, y + 25 - zground, da_opt, target);
}
Index: main.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/main.cc,v
retrieving revision 1.39.2.22
retrieving revision 1.39.2.23
diff -C2 -r1.39.2.22 -r1.39.2.23
*** main.cc 4 Apr 2002 18:10:54 -0000 1.39.2.22
--- main.cc 9 Apr 2002 12:29:55 -0000 1.39.2.23
***************
*** 165,169 ****
mobj = (map_object_with_gfx *)lmap.add_map_object();
mobj->load("adontest/sandy.mobj");
!
mobj = (map_object_with_gfx *)lmap.add_map_object();
mobj->load("adontest/rug.mobj");
--- 165,169 ----
mobj = (map_object_with_gfx *)lmap.add_map_object();
mobj->load("adontest/sandy.mobj");
!
mobj = (map_object_with_gfx *)lmap.add_map_object();
mobj->load("adontest/rug.mobj");
Index: landmap.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/landmap.h,v
retrieving revision 1.24.4.11
retrieving revision 1.24.4.12
diff -C2 -r1.24.4.11 -r1.24.4.12
*** landmap.h 3 Apr 2002 16:03:20 -0000 1.24.4.11
--- landmap.h 9 Apr 2002 12:29:55 -0000 1.24.4.12
***************
*** 24,27 ****
--- 24,29 ----
{
public:
+ s_int32 zground;
+
map_placeable * obj;
***************
*** 46,55 ****
typedef vector <mapsquare_info>::iterator iterator;
! iterator begin ()
{
return objects.begin ();
}
! iterator end ()
{
return objects.end ();
--- 48,57 ----
typedef vector <mapsquare_info>::iterator iterator;
! iterator begin ()
{
return objects.begin ();
}
! iterator end ()
{
return objects.end ();
***************
*** 57,62 ****
--- 59,81 ----
bool add (map_placeable * obj, map_coordinates & pos);
+ bool add (map_moving * obj);
bool remove (map_placeable * obj, map_coordinates & pos);
bool exist (map_placeable * obj, map_coordinates & pos);
+
+ mapsquare_info * project_moving(map_moving & obj)
+ {
+ // map_placeable_area * movstat = obj.current_state();
+
+ mapsquare::iterator it = begin();
+ while (it != end())
+ {
+ map_placeable_area * objstat = it->obj->current_state();
+ if (obj.z() + obj.climb_capability() > it->z() + objstat->zsize)
break;
+ ++it;
+ }
+
+ if (it == end()) return NULL;
+ return NULL;
+ }
};
Index: landmap.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/landmap.cc,v
retrieving revision 1.18.2.12
retrieving revision 1.18.2.13
diff -C2 -r1.18.2.12 -r1.18.2.13
*** landmap.cc 4 Apr 2002 18:10:54 -0000 1.18.2.12
--- landmap.cc 9 Apr 2002 12:29:55 -0000 1.18.2.13
***************
*** 20,23 ****
--- 20,24 ----
: map_coordinates (pos)
{
+ zground = pos.z();
}
***************
*** 30,35 ****
// z() >= mi.z() + mi.obj->current_state()->zsize) return false;
! if (z() + obj->current_state()->zsize <= mi.z()) return true;
! if (z() >= mi.z() + mi.obj->current_state()->zsize) return false;
if (y() < mi.y()) return true;
if (y() > mi.y()) return false;
--- 31,36 ----
// z() >= mi.z() + mi.obj->current_state()->zsize) return false;
! if (z() + obj->current_state()->zsize <= mi.zground) return true;
! if (zground >= mi.z() + mi.obj->current_state()->zsize) return false;
if (y() < mi.y()) return true;
if (y() > mi.y()) return false;
***************
*** 37,42 ****
if (oy() > mi.oy()) return false;
! if (obj->type() == OBJECT) return true;
! if (obj->type() == CHARACTER) return false;
// if (z() + obj->current_state()->zsize < mi.z() +
mi.obj->current_state()->zsize) return true;
// if (z() + obj->current_state()->zsize > mi.z() +
mi.obj->current_state()->zsize) return false;
--- 38,43 ----
if (oy() > mi.oy()) return false;
! // if (obj->type() == OBJECT) return true;
! // if (obj->type() == CHARACTER) return false;
// if (z() + obj->current_state()->zsize < mi.z() +
mi.obj->current_state()->zsize) return true;
// if (z() + obj->current_state()->zsize > mi.z() +
mi.obj->current_state()->zsize) return false;
***************
*** 67,70 ****
--- 68,83 ----
}
+ bool mapsquare::add (map_moving * obj)
+ {
+ mapsquare_info mi (*obj);
+ mi.obj = obj;
+ mi.zground = obj->zground;
+ vector<mapsquare_info>::iterator it = objects.begin();
+ while(it != objects.end() && mi.z() + mi.obj->current_state()->zsize <
+ it->z() + it->obj->current_state()->zsize) ++it;
+ objects.insert(it, mi);
+ return true;
+ }
+
bool mapsquare::remove (map_placeable * obj, map_coordinates & pos)
{
***************
*** 147,151 ****
bool landmap::put (map_moving * obj)
{
! return put (obj, *obj);
}
--- 160,194 ----
bool landmap::put (map_moving * obj)
{
! u_int16 i, j;
! map_placeable_area * state = obj->current_state ();
!
! if (!state) return false;
!
! u_int16 sx = obj->x () < state->base.x () ? 0 :
! obj->x () - state->base.x ();
! u_int16 sy = obj->y () < state->base.y () ? 0 :
! obj->y () - state->base.y ();
!
! u_int16 fx = obj->x () + state->area_length () - state->base.x ();
! u_int16 fy = obj->y () + state->area_height () - state->base.y ();
!
! if (obj->ox ()) fx++;
! if (obj->oy ()) fy++;
!
! if (fx > length()) fx = length() - 1;
! if (fy > height()) fy = height() - 1;
!
! mapsquare * msqr;
!
! for (j = sy; j < fy; j++)
! for (i = sx; i < fx; i++)
! {
! msqr = get (i, j);
! msqr->add (obj);
! }
!
! return true;
!
! // return put (obj, *obj);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src map_placeable_area.h,1.1.2.5,1.1.2.6 map_moving.h,1.1.2.7,1.1.2.8 map_moving.cc,1.1.2.13,1.1.2.14 map_character_with_gfx.cc,1.1.2.10,1.1.2.11 main.cc,1.39.2.22,1.39.2.23 landmap.h,1.24.4.11,1.24.4.12 landmap.cc,1.18.2.12,1.18.2.13,
Alexandre Courbot <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/po Makefile.in.in,1.2,1.3
- Next by Date:
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit Makefile.am,1.42,1.43 dlg_circle_entry.cc,1.2,1.3 dlg_compiler.cc,1.2,1.3 gui_dlgedit.cc,1.2,1.3 gui_dlgedit.h,1.2,1.3 main.cc,1.53,1.54
- Previous by thread:
[Adonthell-commits] CVS: adonthell/po Makefile.in.in,1.2,1.3
- Next by thread:
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit Makefile.am,1.42,1.43 dlg_circle_entry.cc,1.2,1.3 dlg_compiler.cc,1.2,1.3 gui_dlgedit.cc,1.2,1.3 gui_dlgedit.h,1.2,1.3 main.cc,1.53,1.54
- Index(es):