Wucker Posted January 8, 2012 Author Share Posted January 8, 2012 welcome to my first tutorial :cheesy:yami told me to mess with the d3d code of CS:DE, and i also needed the minimap system 7 made for EO, so i just rewrote the thing which came out in about 10 mins.Tutorial:Goto the modDirectX8 and after```Public Tex_Fader As Long```add```Public Tex_Minimap As Long```now in EngineCacheTextures, after``` Tex_Shadow = SetTexturePath(App.path & Path_Graphics & "shadow.png")```add``` Tex_Minimap = SetTexturePath(App.path & Path_Graphics & "minimap.png")```then at the bottom of the mod, paste this:```Public Sub DrawMinimap() Dim x As Long, y As Long, minimap_x As Long, minimap_y As Long, maxX As Long, maxY As Long Dim i As Long Dim mapnum As Long mapnum = Player(MyIndex).Map maxX = Map.maxX maxY = Map.maxY ' render For x = 0 To maxX For y = 0 To maxY Select Case Map.Tile(x, y).Type Case TILE_TYPE_BLANK minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 0, 4, 4, 4, 4 Case TILE_TYPE_WALKABLE, TILE_TYPE_NPCAVOID minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 4, 4, 4, 4, 4 Case TILE_TYPE_BLOCKED minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4 End Select Next Next ' dir blocks For x = 0 To maxX For y = 0 To maxY If Map.Tile(x, y).DirBlock >= 1 Then minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4 End If Next Next ' players For i = 1 To MAX_PLAYERS If Player(i).Vital(1) > 0 Then x = Player(i).x y = Player(i).y minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 0, 4, 4, 4, 4 End If Next ' npcs For i = 1 To MAX_MAP_NPCS If MapNpc(i).num > 0 Then x = MapNpc(i).x y = MapNpc(i).y minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 4, 4, 4, 4, 4 End If NextEnd Sub```then in modText, in DrawMapAttributes, before the End Select, add``` Case TILE_TYPE_BLANK RenderText Font_Default, "BL", tX, tY, White```then in modConstants, below (AND IN SERVER TOO)```Public Const TILE_TYPE_CHAT As Byte = 15```add```Public Const TILE_TYPE_BLANK As Byte = 16```then in modGlobals, at the bottom add```' minimap flagPublic bMinimap As Boolean```Then in modDirectX8, RenderGraphics, after``` ' draw the messages For i = 1 To MAX_BYTE If chatBubble(i).active Then DrawChatBubble i End If Next```add``` If bMinimap Then DrawMinimap```Now in frmEditor_Map, in fraAttributes, add an opttion named optBlank.then, in modGameEditors, MapEditorMouseDown, add, before the End With:``` If frmEditor_Map.optBlank.value Then .Type = TILE_TYPE_BLANK```and finally in modInput, HandleKeyPresses, before``` ' // Monitor Admin Commands //```add``` Case "/minimap" bMinimap = Not bMinimap```also, download this and put it in your data files/graphics/ folder:http://i.imgur.com/njjuK.pngHope you enjoy, and tell me if anything goes wrongEDIT: screenshot:![](http://i.imgur.com/uu49v.png) Link to comment Share on other sites More sharing options...
Whackeddie99 Posted January 8, 2012 Share Posted January 8, 2012 Wow, looks great man. I would definitely use if my game was being made with CS:DE Link to comment Share on other sites More sharing options...
Robin Posted January 8, 2012 Share Posted January 8, 2012 Why do you do so many checks? Cache the positions and re-set them when packets arrive. Don't just re-calculate everything each loop.Caching is your friend. Link to comment Share on other sites More sharing options...
Wucker Posted January 8, 2012 Author Share Posted January 8, 2012 You mean something like this?```Public Sub DrawMinimap() Dim x As Long, y As Long, minimap_x As Long, minimap_y As Long, MaxX As Long, MaxY As Long Dim i As Long Dim MapNum As Long MapNum = Player(MyIndex).Map MaxX = Map.MaxX MaxY = Map.MaxY ' render For x = 0 To MaxX For y = 0 To MaxY minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) Select Case Map.Tile(x, y).Type Case TILE_TYPE_BLANK RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 0, 4, 4, 4, 4 Case TILE_TYPE_WALKABLE, TILE_TYPE_NPCAVOID RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 4, 4, 4, 4, 4 Case TILE_TYPE_BLOCKED RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4 End Select ' dir blocks If Map.Tile(x, y).DirBlock >= 1 Then RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4 End If Next Next ' players For i = 1 To MAX_PLAYERS If Player(i).Vital(1) > 0 Then x = Player(i).x y = Player(i).y minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 0, 4, 4, 4, 4 End If Next ' npcs For i = 1 To MAX_MAP_NPCS If MapNpc(i).num > 0 Then x = MapNpc(i).x y = MapNpc(i).y minimap_x = Camera.left + 600 + (x * 4) minimap_y = Camera.top + 25 + (y * 4) RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 4, 4, 4, 4, 4 End If NextEnd Sub``` Link to comment Share on other sites More sharing options...
Robin Posted January 8, 2012 Share Posted January 8, 2012 The fact that it's in 'DrawMinimap' means I'm not even going to read that code.If it's in the draw routine then it's getting called every single loop. What you want to do is cache it in memory and re-build the cache when the data changes from incoming packets.Then you can render that without all the calculations. Link to comment Share on other sites More sharing options...
Wucker Posted January 8, 2012 Author Share Posted January 8, 2012 sorry to say, but i really don't know what you mean. i really haven't done such thing as caching by myself, and i don't get what you mean by incoming packets. Would doing this increase performance or something? Link to comment Share on other sites More sharing options...
Ariel Posted June 10, 2012 Share Posted June 10, 2012 Works Somtthhily! thanks!!!:) Link to comment Share on other sites More sharing options...
tslusny Posted June 11, 2012 Share Posted June 11, 2012 No it dont work smoothly try to resize map to bigger size, minimap will just shake like ….... when you moving Link to comment Share on other sites More sharing options...
JohnPony Posted June 11, 2012 Share Posted June 11, 2012 Yeah i had the problem too, im just to lazy to figure out whats wrong atm. Link to comment Share on other sites More sharing options...
tslusny Posted June 11, 2012 Share Posted June 11, 2012 and that fps drop is soo bad, i think it need caching Link to comment Share on other sites More sharing options...
Synergy Posted June 11, 2012 Share Posted June 11, 2012 @Deathbeam:> and that fps drop is soo bad, i think it need cachingDefinitely. I put it in then took it out straight away.I haven't a clue how you'd cache it though, so I'll wait till someone does it then find out. :P Link to comment Share on other sites More sharing options...
Exception Posted June 11, 2012 Share Posted June 11, 2012 Little tip: It involves calling a sub to re-initialise the values every time you change maps, and the drawing sub has been modified to just render the already calculated values, and that alone.If you're stuck for that, look at how the actual map drawing itself works, and look at how beforehand, all of the TilesetX/Y, Tileset, etc, values have already been initialised and calculated for use, and aren't just looping every call. Link to comment Share on other sites More sharing options...
Ariel Posted June 12, 2012 Share Posted June 12, 2012 does anybody fixed the shaking map issue when map is bigger then 24? :O Link to comment Share on other sites More sharing options...
Exception Posted June 12, 2012 Share Posted June 12, 2012 @Ariel:> does anybody fixed the shaking map issue when map is bigger then 24? :OSo, I take it you completely ignored me? Link to comment Share on other sites More sharing options...
Ariel Posted June 12, 2012 Share Posted June 12, 2012 OK then if i get this right, cache is just Storing the data in a temporary file on client side so the server wont need to send each time?i need to take the info from the cache and not to calculate each time right? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now