Loffen Posted September 11, 2004 Posted September 11, 2004 My questions list: 1. What is the best map format? I have seen tilebased games use mapformats like this: MyMap;10;5 1111111111 1000000001 1002222001 1000000001 1111111111 The first line is the config line and the rest: 0 = grass, 1 = wall, 2 = water, etc..... Is this a good map format? 2. Storing maps in memory... I read in some free chapter of a book, they stored each tile in an own vertexbuffer. But somewhere else i read that they stored the whole map in a vertexbuffer and just moved the vertexbuffer or something... Whats the best way here?? 3. Displaying maps Whats the best way to display maps?? When the player moves around, should i move the map or the camera and player? 4. Players (and buildnings ?) Should i put all players/units in one vertexbuffer or in separate? If I put all players in one vertexbuffer can i still moev and rotate each of them?? Should i put all buildnings in one vertexbuffer? Some of the buildnings as 'the super automated turret' :p need to rotate a little. Can i do this if all are in one vertexbuffer? Quote Erutangis a si tahw
samsmithnz Posted September 11, 2004 Posted September 11, 2004 You should direct this question to the isometric forums at gamedev.net, they'll be able to help you. Quote Thanks Sam http://www.samsmith.co.nz
ThePentiumGuy Posted September 11, 2004 Posted September 11, 2004 Heh. I've got some answers: 1) I use the same format too, but u should do 1 thing: Seperate each entry with columns. 2) I have my own sprite class, and each tile is a sprite - so i use a vertex buffer for each tile, im not sure if this is memory efficient or not - but 1 vertex buffer can only hold so many vertices. 3) -Whats the best way to display maps?? Store all the tiles into 1 map array and in a loop render all the tiles -When the player moves around, should i move the map or the camera and player? Have you done transformations yet? You should move the map :). In my game, I keep the player stays centered on the screen. So I never move his position. 4) Again, I made my own sprite class - each of my players/objects/WHATEVER go in their own seperate vertex buffer. I don't think (although im not sure) that when you have multiple objects in 1 vertex buffer, you can rotate them individually. So I stored them in different vertex buffers. -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 11, 2004 Author Posted September 11, 2004 Thanks alot both of you! :D Now as i know some efficent ways ill look deeper into vertexbuffers and code my own sprite class(?)... --Loffen Quote Erutangis a si tahw
ThePentiumGuy Posted September 11, 2004 Posted September 11, 2004 Heh, yeah they're mainly C++ people ;), and half the time when you make a post, about 300 other people make a post right after you and your post is like in the 10th page :). The GOOD thing about that site is if someone does end up reading it, you'll get an answer within seconds - there are thousands of people at that site all the time. -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 (edited) What is a title? :p Ok, I fixed a sprite class. I am reading the file line after line, then i split each line into a multidimensional array. Like this: MapTiles(row, tile) = TileNum This gives me an array something like this: MapTiles(1,1) = 0 MapTiles(1,2) = 0 MapTiles(2,1) = 1 MapTiles(2,2) = 0 MapTiles(3,1) = 1 MapTiles(3,2) = 1 How do you create a map from this from this?? Is this an efficent way?? BTW: I will try to move the camera and the player, after some planning i figured it will be easier to make a multiplayer thing if i can send player coords to the server... BTW2: Do you know somewhere with nice 2D Collision detection docs?? EDIT: BTW3: Does someone know why dbmon.exe stops working with 9.0c?? Am i doning something wrong or did you experience the same?? Edited September 12, 2004 by Loffen Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 heh, btw2: www.vbprogramming.8k.com - look in the Tile Based Collision Detection tutorials (its with GDI+ but you should be able to apply the concept to d3d) How do you create a map from this from this?? Is this an efficent way?? Here's what I did in my game: for example you have this: MapTiles(3,2) = 1 You'd simply create a tile at (3,2) which uses 1.jpg.. mine works like: for x = 0 to mapwidth for y = 0 to mapheight CreateATile( maptiles(x,y) & ".jpg", x*tileWidth, y *tileHeight) next next Where the first argument is what bitmap is displayed where the 2nd and 3rd arguments are the posijtion of the tile. Ex: If x was 3, and y was 2.. "MapTiles(3,2) = 1" and tilewidthwas 30 and tileHeight was 30: then the compiler would read it as CreateATile("1.jpg", 90, 60) The whole x*tilewidh, y*tileheight concept is simple - if you don't understand it i think i included some explanation in my tutorial -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 (edited) Oh my! You site is uber bannered :p About coll. det. I was thinking smooth movement (one pixel each time, not one tile...) is this way harder?? I read an article somewhere, something about a special way of coll. det., very easy, accurate and you can move pixel by pixel... (where i dreaming or could this be true?) Got your example... :D. But my sprite class suddenly stopped showing the sprites. What am i doing wrong do you think :confused: ? Here it is: Imports Microsoft.DirectX Imports Microsoft.DirectX.Direct3D Imports Microsoft.DirectX.Direct3D.D3DX Imports System.Math Public Class FearGraphicsSprite Private pDevice As Device Private SpriteImage As Texture Private SpriteBuffer As VertexBuffer Public Sub New(ByVal lDevice As Device, ByVal ImageName As String, ByVal TopLeft As Point, ByVal Width As Integer, ByVal Height As Integer) pDevice = lDevice Load(ImageName, TopLeft, Width, Height) End Sub Public Sub Load(ByVal ImageName As String, ByVal topleft As Point, ByVal width As Integer, ByVal height As Integer) Dim Vertices() As CustomVertex.PositionTextured Try SpriteImage = TextureLoader.FromFile(pDevice, ImageName) Catch MessageBox.Show("Could not load image: " & ImageName, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End End Try SpriteBuffer = New VertexBuffer(GetType(CustomVertex.PositionTextured), 4, pDevice, Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default) Vertices = SpriteBuffer.Lock(0, LockFlags.None) Vertices(0) = New CustomVertex.PositionTextured(topleft.X, topleft.Y, 1, 0, 0) Vertices(1) = New CustomVertex.PositionTextured(topleft.X + width, topleft.Y, 1, 1, 0) Vertices(2) = New CustomVertex.PositionTextured(topleft.X, topleft.Y + height, 1, 0, 1) Vertices(3) = New CustomVertex.PositionTextured(topleft.X + width, topleft.Y + height, 1, 1, 1) SpriteBuffer.Unlock() End Sub Public Sub Render() pDevice.VertexFormat = CustomVertex.PositionTextured.Format pDevice.SetStreamSource(0, SpriteBuffer, 0) pDevice.SetTexture(0, SpriteImage) pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 3) End Sub End Class Yes we did think a little of the same. Saw your class somewhere on these forums... EDIT: I tried your class too... still nothing Edited September 12, 2004 by Loffen Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 Oh my! You site is uber bannered :p Hehe! that's the probelem with having a free site ;). About coll. det. I was thinking smooth movement (one pixel each time, not one tile...) is this way harder?? I read an article somewhere, something about a special way of coll. det., very easy, accurate and you can move pixel by pixel... (where i dreaming or could this be true?)This can be accomplished easily. Lets say the dude is on tile 20,20, and the size of each tile is 30x30. This means that he's on tile 0,0 - if he's on 50,50, he's on tile 1,1.. The algorithm to compute his position is pretty basic and you can figure it out when you plug in numbers: TilePos = new Point( Math.Floor(Position.X / tileWidth), Math.Floor(Position.Y / tileHeight) Floor, btw, rounds DOWN. So, e.g back to the 20,20 example: 20/30, 20/30 = .666,.666 .. math.Floor would round it to 0,0 as opposed to 1,1. That's the algorithm to compute the tile he's on. To move him, you simply eliminate the loop and use the same collision detection algorithm - with a few tweaks of course.. for example if the guy is at 40,40 and wants to go to tile 0,0. After he gets to 29,29 he cannot move left anymore [ if you've set it so that he can't go to the left of 0,0] becuase 29/30, 29/30 -> 0,0 and if you want to compute collision for the tile to the LEFT of 0,0 (whcih is -1,0) it says "No" becuase that's not possible, and it wont let you move further left!... this requires a few tweaks like I said Got your example... :D. But my sprite class suddenly stopped showing the sprites. What am i doing wrong do you think :confused: ? Heh - .. did you render the sprite? Yes we did think a little of the same. Saw your class somewhere on these forums... :) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 Yup i do render it: Graphics.Sprite = New GraphicsSprite(Graphics.Device, "grass.bmp", New Point(0, 0), 32, 32) Then in Render(): Graphics.Sprite.Render() Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 What matrices have you set? Be sure to set them right - on my tutorials i've set the View Matrix to OrthoOffCenterLH(0,1024,768,0) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 (edited) Poff... Feel suddenly small :p. The only thing i set looking like this is: Device.Transform.Projection = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, 0, PP.BackBufferHeight, 0.0F, 0.0F) Device.Transform.Projection = Projection Matrix?? EDIT: I noticed that the order of OrthoOffCenterLH was not left, right, top, bottom but left, right, bottom, top. So therefore i changed my code to this: Device.Transform.Projection = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, PP.BackBufferHeight, 0, 0.0F, 0.0F) Still no result though :p BTW: Hehe! that's the probelem with having a free site http://www.freewebs.com/ is free. No AD's (last time i was there) the only thing is a little copyright line... Edited September 12, 2004 by Loffen Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 its VIEW not projection :). Projection is used for 3d to tell the device how the scene should be displayed (like, should you see 45 degrees of the screen, should you see 90 degrees.., aspect ration....etc) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 Tried both now... :( Should i post my whole project?? Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 Device.Transform.Projection = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, PP.BackBufferHeight, 0, 0.0F, 0.0F) The last argument shouild be > 0 I think. If it was 0, you're "Cutting off" all the objects with a Z which have greater than 0 and less than... 0 ;). Put like... 5 or somethign for the last argument, it really doesn't matter :-P. Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 Did it like this (the same as you in Tutorial #2): Device.Transform.View = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, PP.BackBufferHeight, 0, 0, 10) But guess what, Still no result... This makes me very maad........... Quote Erutangis a si tahw
ThePentiumGuy Posted September 12, 2004 Posted September 12, 2004 Turn off lighting: D3DDev.Renderstate.Lighting = False... If this doesn't work, paste your GameClass here :p. Should i post my whole project?? Heh, your gameclass + your Sprite class (whcih you've already pasted) are the majority of your project :P so if you post the gameclass maybe we'll see whats up. Could you clearly explain whats going on? Is it just not showing the sprite? -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted September 12, 2004 Author Posted September 12, 2004 (edited) Ahhhh!!! Got IT!!!! I was using: pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, [color=Red][b]3[/b][/color]) and NOT: pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, [color=Red][b]2[/b][/color]) Rolling around on floor trying to struggle myself with some wires... Thank to all of you who helped me so far... ;) --Loffen Edited September 12, 2004 by Loffen Quote Erutangis a si tahw
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.