-
3d overhead engine
Does anyone have any idea how I would go about making an overhead 3d engine for a gta styled game. I have seen a few of the members work but I wondered what I would need to learn to do the same. Thanks for any advice in advance
-
n00b
Some useful tutorials:
http://www.kirupa.com/developer/acti...pt/3dindex.htm
I had a wall with a tweened scew, a roof clip and a floor clip. The floor clip is empty and the house gets a attached to it. Each wall is a rotated or scaled version of the wall clip plus a roof clip. A floor/house tile gets attached to a ground tile of the tile engine. And then it gets scewed (gotoandstop) and scaled by the distance of the screen center and the floor center. Scaling and scewing of the walls is calculated by a focal lenght and height and distance.
Like mentioned in as 2 the floor clip gets linked to a house class see below.
A bad code example:
Code:
class House extends MovieClip {
public var movit:Number;
public var zdim:Number;
public var wl:MovieClip;
public var wr:MovieClip;
public var wu:MovieClip;
public var wd:MovieClip;
public var rf:MovieClip;
public var fl:MovieClip;
public var tx:Number;
public var ty:Number;
private var rx:Number;
private var ry:Number;
private var rz:Number;
private var tw:Number;
private var th:Number;
private var rw:Number;
private var rh:Number;
private var htw:Number;
private var hth:Number;
private var hrw:Number;
private var hrh:Number;
private var smx:Number;
private var smy:Number;
private var sw:Number;
private var sh:Number;
private var r = Math.round;
private var fc:Number;
private var fcx:Number;
private var fcy:Number;
private var sr:Number;
public var tile:Object;
public var stx:Number;
public var sty:Number;
public function toString():String {
return ("House tile "+tile+" x "+_x+" y "+_y);
}
public function House() {
onLoad = function () {
_visible = false;
var movit = 0;
sw = Stage.width;
sh = Stage.height;
smx = sw/2;
smy = sh/2;
tw = 400;
th = 400;
htw = tw/2;
hth = th/2;
tx = smx-htw;
ty = smy-hth;
_x = tx;
_y = ty;
rz = 800;
fc = 3000;
sr = (fc/(fc-rz));
rf = this.attachMovie("roof", "roofg", 5);
rf._width = tw*sr;
rf._height = th*sr;
rw = rf._width;
rh = rf._height;
hrw = rw/2;
hrh = rh/2;
rx = -((rw-tw)/2);
ry = -((rh-th)/2);
rf._x = rx;
rf._y = rx;
wl = this.attachMovie("wallc", "wl", 1);
wl.stop();
wl.inv.stop();
wr = this.attachMovie("wallc", "wr", 2);
wr._x = tw;
wr._y = th;
wr._rotation = 180;
wr.stop();
wr.inv.stop();
wu = this.attachMovie("wallc", "wu", 3);
wu._x = tw;
wu._rotation = 90;
wu.stop();
wu.inv.stop();
wd = this.attachMovie("wallc", "wd", 4);
wd._x = 0;
wd._y = th;
wd._rotation = -90;
wd.stop();
wd.inv.stop();
};
}
public function update():Void {
_visible = true;
tx = tile._x+stx;
ty = tile._y+sty;
_x = tx;
_y = ty;
var tmx = tx+htw;
var tmy = ty+hth;
var vecx = (tmx-smx);
var vecy = (tmy-smy);
var mvx = vecx*sr;
var mvy = vecy*sr;
mvx -= vecx;
mvy -= vecy;
rx = mvx-((rw-tw)/2);
ry = mvy-((rh-th)/2);
rf._x = rx;
rf._y = ry;
wl._xscale = -rx*sr;
wr._xscale = (rx+(rw-tw))*sr;
wu._xscale = -ry*sr;
wd._xscale = (ry+(rh-th))*sr;
var lgt = (smy-(ty+hth));
lgt /= -10;
lgt = r(lgt);
if (lgt<0) {
lgt *= -1;
wl.gotoAndStop(2);
wr.gotoAndStop(1);
} else {
wl.gotoAndStop(1);
wr.gotoAndStop(2);
}
if (lgt == 0) {
lgt++;
}
var hgt = (smx-(tx+htw));
hgt /= -10;
hgt = r(hgt);
if (hgt == 0) {
hgt++;
}
if (hgt<0) {
hgt *= -1;
wd.gotoAndStop(2);
wu.gotoAndStop(1);
} else {
wd.gotoAndStop(1);
wu.gotoAndStop(2);
}
var lsc = (-rf._x);
if (lsc>0) {
wl.inv.stop();
wl._visible = false;
} else {
wl._visible = true;
wl.inv.gotoAndStop(lgt);
}
var rsc = ((rf._x+rw)-(tw));
if (rsc>0) {
wr.inv.stop();
wr._visible = false;
} else {
wr._visible = true;
wr.inv.gotoAndStop(lgt);
}
var usc = 2*(-rf._y);
if (usc>0) {
wu.inv.stop();
wu._visible = false;
} else {
wu._visible = true;
wu.inv.gotoAndStop(hgt);
}
var dsc = 2*((rf._y+rh)-(th));
if (dsc>0) {
wd.inv.stop();
wd._visible = false;
} else {
wd._visible = true;
wd.inv.gotoAndStop(hgt);
}
}
}
It is basically made to fit to a tile engine so for an art base approach it would be modified a little bit.
Maybe someone can post a better example.
I do stuff that does stuff...
J-Force
-
LeechmasterB - do you have a source .fla of the effect you describe in code working? I'd be interested to see an example?
-
Senior Member
mprimmer, let us know what your programming experience is first. Alot of guys come in here, knowing nothing, but wanting to create 'GTA' in Flash. It's impossible for a newbie to do.
-
Patron Saint of Beatings
Originally Posted by Ray Beez
mprimmer, let us know what your programming experience is first. Alot of guys come in here, knowing nothing, but wanting to create 'GTA' in Flash. It's impossible for a newbie to do.
Actually, even experienced programmers usually quit when trying to do a GTA clone.
A lot of times, it's related to speed issues and such.
-
Yes we can
yup,one or two years back i thought an experienced coder could mimic something like gta (topdown 2d version ) pretty fine in flash. But yeah,since then i worked on several games which were mainly about physics simulations and that made me change my mind a lot
With performance optimised code it´d be possible to simulate a few objects (vehicles) at most,but not loads of cars like in gta and that together with everything else what makes up gta.
The problem is that to solve collisions and react properly sometimes (often actually) its needed to have several detection/reaction iterations per frame refresh.
Either that or the detection/reaction will fail in many cases.
So you can choose between less precise and reliable detection and reaction or less performance.
All that changes with AS3 as its massive code execution improvements help a lot for such things,but yeah,up till F9/Flex2 usage i wouldn´t suggest to anyone to attempt simulating lots of vehicles in realistic manner in flash.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|