• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
codeman_nz

Traversing a large game world

3 posts in this topic

Hi everyone,

 

I am planning a game where the player builds their own city and is inhabited by citizens which they can see moving around.  The players' city will be one of many in a large game world.
 
I want the player to be able to visit other cities but I am not sure how to implement it.  I want the player to scroll smoothly across the game world instead of having something like "Click here to go to Bobs city" and I don't want the player to have to wait for things to load.

 

Any ideas?

0

Share this post


Link to post
Share on other sites

as mentioned, use streaming to avoid load screens, and use a world coordinate system that gets converted to camera relative just before frustum cull and draw.

 

i recently came up with a "generic" system for big game worlds:

 

Int64 lightyears

Int64 centimeters

 

this system is big enough to hold an entire galaxy, with a resolution of 0.01 meters.

 

in your case, if your scale is something like one 3d unit = 1 meter, you might use an int64 decimeters as your coordinate system. this would give you a sufficiently large world, with an accuracy of 0.1 meters, plenty enough for a god game citybuilder / RTS thing.

0

Share this post


Link to post
Share on other sites

in your case, if your scale is something like one 3d unit = 1 meter, you might use an int64 decimeters as your coordinate system. this would give you a sufficiently large world, with an accuracy of 0.1 meters, plenty enough for a god game citybuilder / RTS thing.

No need to stay that coarse if you use a 64-bit integer, 263 nanometers are 9.2 million kilometers. For anything not "space adventure", 9 million kilometers is plenty -- that's about 220 times the circumference of the earth. So, if you want, you can easily use nanometer resolution with 64-bit integers, and never need to waste a thought.

 

If millimeter resolution is enough, and your game world is not larger than "once across the Atlantic Ocean", you can use a 32-bit integer. Which, frankly, for pretty much most people, is just fine.

0

Share this post


Link to post
Share on other sites

You can make a data structure that easily stores your coordinate system. Most of the posts have eluded to this.


 

struct INTVECTOR3{
	INTVECTOR3(){}
	INTVECTOR3(__int64 x,__int64 y,__int64 z){ix=x;iy=y;iz=z;}
	__int64 ix,iy,iz;
	INTVECTOR3 operator + ( CONST INTVECTOR3& other) const;
	INTVECTOR3 operator - ( CONST INTVECTOR3& other) const;
	INTVECTOR3 operator * ( CONST __int64& other) const;
	INTVECTOR3 operator * ( CONST double& other) const;
	INTVECTOR3 operator / ( CONST double& other) const;
	INTVECTOR3 operator / ( CONST __int64& other) const;
	INTVECTOR3& operator -= ( CONST INTVECTOR3& other);
	INTVECTOR3& operator+=( CONST INTVECTOR3& other);
	INTVECTOR3& operator/=( CONST __int64 other);
	INTVECTOR3& operator*=( CONST __int64 other);
	D3DXVECTOR3 Div(double m);
	D3DXVECTOR3 Mul(double m);
};
INTVECTOR3 INTVECTOR3::operator*( CONST double& other) const{
	return INTVECTOR3(__int64(ix*other),__int64(iy*other),__int64(iz*other));
}
INTVECTOR3 INTVECTOR3::operator*( CONST __int64& other) const{
	return INTVECTOR3(ix*other,iy*other,iz*other);
}
INTVECTOR3 INTVECTOR3::operator/( CONST __int64& other) const{
	return INTVECTOR3(ix/other,iy/other,iz/other);
}
INTVECTOR3 INTVECTOR3::operator/( CONST double& other) const{
	return INTVECTOR3(int(ix/other),int(iy/other),int(iz/other));
}
INTVECTOR3 INTVECTOR3::operator+( CONST INTVECTOR3& other) const{
	return INTVECTOR3(ix+other.ix,iy+other.iy,iz+other.iz);
}
INTVECTOR3 INTVECTOR3::operator-( CONST INTVECTOR3& other) const{
	return INTVECTOR3(ix-other.ix,iy-other.iy,iz-other.iz);
}
INTVECTOR3& INTVECTOR3::operator-=( CONST INTVECTOR3& other){
	this->ix-=other.ix;
	this->iy-=other.iy;
	this->iz-=other.iz;
	return *this;
}
INTVECTOR3& INTVECTOR3::operator+=( CONST INTVECTOR3& other){
	this->ix+=other.ix;
	this->iy+=other.iy;
	this->iz+=other.iz;
	return *this;
}
INTVECTOR3& INTVECTOR3::operator/=( CONST __int64 other){
	this->ix/=other;
	this->iy/=other;
	this->iz/=other;
	return *this;
}
INTVECTOR3& INTVECTOR3::operator*=( CONST __int64 other){
	this->ix*=other;
	this->iy*=other;
	this->iz*=other;
	return *this;
}
D3DXVECTOR3 INTVECTOR3::Div(double m){
	float x=float(ix);
	float y=float(iy);
	float z=float(iz);
	x/=float(m);
	y/=float(m);
	z/=float(m);
	ix=__int64(x);
	iy=__int64(y);
	iz=__int64(z);
	D3DXVECTOR3 v;
	v=D3DXVECTOR3(x-float(ix),y-float(iy),z-float(iz));
	return v;
}
D3DXVECTOR3 INTVECTOR3::Mul(double m){
	double x=double(ix);
	double y=double(iy);
	double z=double(iz);
	x*=double(m);
	y*=double(m);
	z*=double(m);
	ix=__int64(x);
	iy=__int64(y);
	iz=__int64(z);
	D3DXVECTOR3 v;
	v=D3DXVECTOR3(float(x)-float(ix),float(y)-float(iy),float(z)-float(iz));
	return v;
}
struct HUGEVECTOR3{
	HUGEVECTOR3(){Sector=INTVECTOR3(0,0,0);Loc=D3DXVECTOR3(0,0,0);};
	HUGEVECTOR3(INTVECTOR3 s,D3DXVECTOR3 l){Sector=s;Loc=l;}
	HUGEVECTOR3(D3DXVECTOR3 l){Sector=INTVECTOR3(0,0,0);Loc=l;}
	HUGEVECTOR3(INTVECTOR3 s){Sector=s;Loc=D3DXVECTOR3(0,0,0);}
	HUGEVECTOR3 operator * ( CONST double& other) const;
	HUGEVECTOR3 operator / ( CONST double& other) const;
	HUGEVECTOR3 operator + ( CONST HUGEVECTOR3& other) const;
	HUGEVECTOR3 operator - ( CONST HUGEVECTOR3& other) const;
	HUGEVECTOR3& operator-=( CONST HUGEVECTOR3& other);
	HUGEVECTOR3& operator+=( CONST HUGEVECTOR3& other);
	HUGEVECTOR3& operator-=( CONST D3DXVECTOR3& other);
	HUGEVECTOR3& operator+=( CONST D3DXVECTOR3& other);
	HUGEVECTOR3& operator/=( CONST double other);
	HUGEVECTOR3& operator*=( CONST double other);

	INTVECTOR3 Sector;
	D3DXVECTOR3 Loc;
	double Length;
	void CheckScale(void);
	double GetLength(void);
	double GetLargeLengthKM(void);//returns distance in kilometers
	__int64 GetLargeLength(void);
	D3DXVECTOR3 Normalize(void);
};
double HUGEVECTOR3::GetLargeLengthKM(void){//returns distance in kilometers
	HUGEVECTOR3 tmp;
	tmp.Sector=Sector;
	tmp.Sector.ix/=1000;
	tmp.Sector.iy/=1000;
	tmp.Sector.iz/=1000;
	tmp.Loc=Loc/1000.0f;

	tmp.Loc.x+=float(Sector.ix-tmp.Sector.ix*1000);
	tmp.Loc.y+=float(Sector.iy-tmp.Sector.iy*1000);
	tmp.Loc.z+=float(Sector.iz-tmp.Sector.iz*1000);

	return tmp.GetLength();
}
__int64 HUGEVECTOR3::GetLargeLength(void){
	__int64 L;
	L=__int64(sqrt((long double(Sector.ix*Sector.ix)+long double(Sector.iy*Sector.iy)+long double(Sector.iz*Sector.iz))));
	return L*1000;

}
double HUGEVECTOR3::GetLength(){
	long double Dsq=(long double(Sector.ix*1000)+Loc.x)*(long double(Sector.ix*1000)+Loc.x)
		+(long double(Sector.iy*1000)+Loc.y)*(long double(Sector.iy*1000)+Loc.y)
		+(long double(Sector.iz*1000)+Loc.z)*(long double(Sector.iz*1000)+Loc.z);
	double sr=sqrtl(Dsq);
	Length=sr;
	return sr;

}
D3DXVECTOR3 HUGEVECTOR3::Normalize(){
	Length=GetLength();
	if (Length>0.0f){
		float x=float((float(Sector.ix*1000.0f)+Loc.x)/Length);
		float y=float((float(Sector.iy*1000.0f)+Loc.y)/Length);
		float z=float((float(Sector.iz*1000.0f)+Loc.z)/Length);
		return D3DXVECTOR3(x,y,z);
	}
	return D3DXVECTOR3(0,0,0);
}
void HUGEVECTOR3::CheckScale(void){
	if ((this->Loc.x>=1000.0f)||(this->Loc.x<0.0f)){
		int x=int(this->Loc.x)-int(this->Loc.x)%1000;
		this->Loc.x-=float(x);
		this->Sector.ix+=__int64(x/1000);
	}
	if ((this->Loc.y>=1000.0f)||(this->Loc.y<0.0f)){
		int y=int(this->Loc.y)-int(this->Loc.y)%1000;
		this->Loc.y-=float(y);
		this->Sector.iy+=__int64(y/1000);
	}
	if ((this->Loc.z>=1000.0f)||(this->Loc.z<0.0f)){
		int z=int(this->Loc.z)-int(this->Loc.z)%1000;
		this->Loc.z-=float(z);
		this->Sector.iz+=__int64(z/1000);
	}
}
HUGEVECTOR3& HUGEVECTOR3::operator+=( CONST D3DXVECTOR3& other){
	this->Loc+=other;
	CheckScale();
	return *this;
}
HUGEVECTOR3& HUGEVECTOR3::operator-=( CONST D3DXVECTOR3& other){
	this->Loc-=other;
	CheckScale();
	return *this;
}
HUGEVECTOR3& HUGEVECTOR3::operator+=( CONST HUGEVECTOR3& other){
	this->Loc+=other.Loc;
	this->Sector+=other.Sector;
	CheckScale();
	return *this;
}
HUGEVECTOR3& HUGEVECTOR3::operator-=( CONST HUGEVECTOR3& other){
	this->Loc-=other.Loc;
	this->Sector-=other.Sector;
	CheckScale();
	return *this;
}

HUGEVECTOR3 HUGEVECTOR3::operator*( CONST double& other) const{
	HUGEVECTOR3 tmp;
	tmp.Loc=Loc*float(other);
	tmp.Sector=Sector*other;
	tmp.CheckScale();
	return tmp;
}
HUGEVECTOR3 HUGEVECTOR3::operator/( CONST double& other) const{
	HUGEVECTOR3 tmp;
	tmp.Loc=Loc/float(other);
	tmp.Sector=Sector/other;
	tmp.CheckScale();
	return tmp;
}
HUGEVECTOR3 HUGEVECTOR3::operator+( CONST HUGEVECTOR3& other) const{
	HUGEVECTOR3 tmp;
	tmp.Loc=Loc+other.Loc;
	tmp.Sector=Sector+other.Sector;
	tmp.CheckScale();
	return tmp;
}
HUGEVECTOR3 HUGEVECTOR3::operator-( CONST HUGEVECTOR3& other) const{
	HUGEVECTOR3 tmp;
	tmp.Loc=Loc-other.Loc;
	tmp.Sector=Sector-other.Sector;
	tmp.CheckScale();
	return tmp;
}
HUGEVECTOR3& HUGEVECTOR3::operator *= ( CONST double other) {
	this->Loc*=float(other);
	this->Loc+=(this->Sector.Mul(other))*1000.0f;
	this->CheckScale();
	return *this;
}
HUGEVECTOR3& HUGEVECTOR3::operator /= ( CONST double other) {
	this->Loc/=float(other);
	this->Loc+=(this->Sector.Div(other))*1000.0f;
	this->CheckScale();
	return *this;
}

This is the data structure I made for my space game. It is for 3D, but it can be modified to be 2D.

Edited by Hawkblood
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0