|
-
Apr 16th, 2005, 02:52 PM
#1
Thread Starter
Member
RTS-like scrolling screen
I'm planning on making a simple (very) RTS-like game, and atm I'm stumped on displaying a scrollable screen, such as one in any RTS game, where not the whole "world" is displayed at the same time, just a smallish area of it.
My thoughts would be that everything is done before being rendered (normal i think), and each unit in my RTS game (prob based on a real simple 2D grid) would be given world co-ords, not screen co-ords, and when the game renders, it...
and here i am stuck :S i guess you need some conversations from world co-ords to screen co-ords, and the position of the users screen in the world - which work together sort of... basicly, i don't know where to start! so any help is welcome! and i would prefer the screen to "move" when the cursor nears the edge of the map, although i think i know how to do this.
and one small question, from another thread which was never answered about vbScript:
i've added some scripting support to my basic game, and so far have this:
With frmMain.SC
.Reset
.AddObject "Game", Game
.AddObject "User", User
.AddCode LoadedItem(Item(ID).intLoadedItemOrigin).strEffect
.Run "Effect"
End With
This works fine, and I am able to "use" all public members in both of these arrays. But I would like to add another class object that is an array, how can you do this? or is this even possible?
i mean something like this : .addobject "Item", Item(), althoughthis doesn't work
Thanks
-
Apr 16th, 2005, 03:58 PM
#2
Re: RTS-like scrolling screen
You use D3DXVec3Project to convert world coordinates to screen coordinates. The VOut result, although it says D3DVECTOR, it's actually a vertex it's returning, which would be your screen coordinates.
VB Code:
Function D3DXVec3Project(VOut As D3DVECTOR, v As D3DVECTOR, viewport As D3DVIEWPORT8, Projection As D3DMATRIX, view As D3DMATRIX, World As D3DMATRIX) As Long
-
Apr 16th, 2005, 05:20 PM
#3
Thread Starter
Member
Re: RTS-like scrolling screen
ok, so i need viewport, matrixworlds and projectoring thingys to do this (properly)?
ill get on it then tutorials here we come
-
Apr 17th, 2005, 03:40 AM
#4
Thread Starter
Member
Re: RTS-like scrolling screen
erm can anyone link me to tutorial dealing with this stuff, as I don't really know what to search for!
thanks
-
Apr 17th, 2005, 05:43 AM
#5
Hyperactive Member
Re: RTS-like scrolling screen
-
Apr 17th, 2005, 09:33 AM
#6
Thread Starter
Member
Re: RTS-like scrolling screen
right, i'm having mighty trouble with this D3DXMatrixLookAtLH thingy for the viewport!
atm, i have a basic cube, and am currently trying to make it so that when you press vbKeyLeft, the "camera" moves left, vbKeyRight moves it "right", vbKeyUp moves it closer to the cube, and vbKeyDown moves it further away from it.
like so:
Code:
[cube]
vbkeyup
|
\ | /
\_____/
| |
vbkeyleft<-- |Cam| --> vbKeyRight
|___|
|
|
vbkeydown
if that makes any sense
it says makevector(), and so i think this means you dont tell the camera where to go, you tell it how far to move, is that correct?
also, i am using :
VB Code:
D3DXMatrixLookAtLH matView, MakeVector(whtX, whtY, whtZ), MakeVector(0, 0, 0), MakeVector(0, 0, 1)
to move the camera, can someone explain what all the MakeVectors mean? this is what I think: 1st MakeVector tell the camera where to move, 2nd MV tells the camera what to point at, and the last one does.... ? what does it do?
anyways, i am rather stuck with this thing :S if anyone can guide my through then id be most grateful! one last thing, is Z up/down?
-
Apr 17th, 2005, 09:52 AM
#7
Thread Starter
Member
Re: RTS-like scrolling screen
ok, sorry, solved my own question!
it does just what i wanted it to do, and i understand why it wasnt working before, its because the camera always faced 0,0,0, meaning it would "spiral" around the shape, so here is the code that does what I wanted to do 
VB Code:
If KeyCode = vbKeyUp Then
intX = intX - 0.5
D3DXMatrixLookAtLH matView, MakeVector(intX, intY, intZ), MakeVector(intX - 5, intY, intZ), MakeVector(0, 0, 1)
D3DDevice.SetTransform D3DTS_VIEW, matView
End If
If KeyCode = vbKeyDown Then
intX = intX + 0.5
D3DXMatrixLookAtLH matView, MakeVector(intX, intY, intZ), MakeVector(intX - 5, intY, intZ), MakeVector(0, 0, 1)
D3DDevice.SetTransform D3DTS_VIEW, matView
End If
If KeyCode = vbKeyLeft Then
intY = intY + 0.5
D3DXMatrixLookAtLH matView, MakeVector(intX, intY, intZ), MakeVector(intX - 5, intY, intZ), MakeVector(0, 0, 1)
D3DDevice.SetTransform D3DTS_VIEW, matView
End If
If KeyCode = vbKeyRight Then
intY = intY - 0.5
D3DXMatrixLookAtLH matView, MakeVector(intX, intY, intZ), MakeVector(intX - 5, intY, intZ), MakeVector(0, 0, 1)
D3DDevice.SetTransform D3DTS_VIEW, matView
End If
one question, why is Y the "wrong way" round? shouldn't increasing Y move the camera right? or am i doing something wrong :S thanks again!
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
|