RPG Maps
RPG Maps
RPG Maps
RPG Maps
RPG Maps
RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps
RPG Maps RPG Maps
RPG Maps
Go Back  Xtreme Visual Basic Talk > > > RPG Maps


Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2008, 05:00 PM
BillyM BillyM is offline
Newcomer
 
Join Date: Oct 2005
Posts: 12
Default RPG Maps


Okay, I run into a problem. I have several maps
Code:
'This is for the tiles
Public Type TileSet
    Walkable As Boolean         'Can you walk on this tile?
    Tile As String            'What terrain is it
    Airport As Boolean
    Bank As Boolean
    Gym As Boolean
    SafeZone As Boolean
End Type

Public Map() As TileSet         'Array to hold map.. walkable.. tile
Public Map2() As TileSet
When a player walks into a warp while on Map(), he is then transferred to Map2

On the server, i have it setup like this

Code:
If Players(index).CurrentMap = 1 then
     'Some code here
    
ElseIf Players(index).CurrentMap = 2 Then
     'Some Code here
End if
My question is, what if i want 10 maps? 50 maps? lol, it doesn't seem very efficient to keep addings Elseif Players(index).CurrentMap = 5 or Elseif Players(index).CurrentMap = 34

What's another way to set this up if i have, say 50 maps?
Reply With Quote
  #2  
Old 04-08-2008, 05:51 PM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default

Well, if your current system works for you, you could simply make your maps into an array of maps. Then you just use the player's current map index to point to the map that you want

Code:
Public Type MapData Name as string Tileset as Integer 'perhaps have same tiles with different graphics sheets Tile() as TileSet 'using your definition End Type 'you can nest array's within arrays as long as they are separate types Dim Map(1-10) as MapData 'or dim(0) and use redim preserve to add maps later 'load/access your map data like this Map(index).Tile(X,Y).property
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #3  
Old 04-09-2008, 11:45 PM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

you have to be careful with map arrays because you can run out of memory real fast with gigantic multi-dimensional maps.
__________________
The Pho·net·ic Programmer
Reply With Quote
  #4  
Old 04-10-2008, 07:58 AM
BillyM BillyM is offline
Newcomer
 
Join Date: Oct 2005
Posts: 12
Default

An example wolfstrike? What causes that? Array dimensioned to big? Too many maps?
Reply With Quote
  #5  
Old 04-10-2008, 01:35 PM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

if you try to make something like...


Code:
public type Mapstats
Tile as integer
Wall as integer
Field as integer
"
"
"
end type


public Map(10  ,1000  , 1000 ) as Mapstats  '   map(levels , x , y)


you'll get a "bitmap" error, its too big

you're better off controling the maps manually.
...well that's what i'm planning to do, just by using a switch, haven't tried it yet though.
__________________
The Pho·net·ic Programmer
Reply With Quote
  #6  
Old 04-11-2008, 10:59 PM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default

Quote:
Originally Posted by wolfstrike View Post
you have to be careful with map arrays because you can run out of memory real fast with gigantic multi-dimensional maps.
Very true, and my preference would be towards loading only the information required as required however 50x1000x1000 byte arrays only amounts to 50MB of memory, a small overhead on today's 1GB machines a quick test on my machine shows that you need to specify around 200x1000x1000 integer array to cause an out of memory error.
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #7  
Old 04-15-2008, 05:41 PM
CtrlAltDestroy's Avatar
CtrlAltDestroy CtrlAltDestroy is offline
Centurion
 
Join Date: Dec 2004
Posts: 108
Default

To answer the original poster's question directly, here's how I usually like to handle maps and warping between them. (I'm not copying this from a project or anything, I'm just making it up as I go along)

First, I declare my Tile, Room, and World types. (I like to split my maps up into rooms.) The world type can be potentially huge, but it has a re-sizable array of Rooms in it, so it's only as big as you need it.

Code:
Public Type Tile Floor As Integer Wall As Integer ClipType As Integer '... Etc. End Type Public Type Room TILE_DATA(20, 15) As Tile RoomFlags As Byte RoomBackColor As Long '... Etc. End Type Public Type World ROOM_DATA() As Room WorldFlags As Byte WorldName As String WorldFileName As String WorldScripts As String '... Etc. End Type

Then, I make THISWORLD and THISROOM variables, corresponding to the current world and the current room, and also some position variables so I know exactly which room is the one loaded and where the character is.

Code:
Public THISWORLD As World Public THISROOM As Room Public PlayerCharacterRoomPos As Coordinate Public PlayerCharacterMapPos As Coordinate

Finally, I make four routines called warp1, warp2, warp3, and Warp.

Code:
Sub warp1(POS As Coordinate) 'Warp to a new position in the same room. PlayerCharacterRoomPos = POS End Sub Sub warp2(MapPOS As Coordinate) 'Warp to a different room. THISROOM = THISWORLD.ROOM_DATA(MapPOS.X, MapPOS.Y) PlayerCharacterMapPOS = MapPOS End Sub Sub warp3(WorldName As String) 'Warp to a different world Open App.Path & "\" & WorldName For Input As 1 LoadWorld 1 'Worlds are stored in files Close 1 End Sub Sub Warp(Optional ByVal MapPosX As Integer = 0, Optional ByVal MapPosY As Integer = 0, _ Optional ByVal RoomPosX As Integer = 0, Optional ByVal RoomPosY As Integer = 0, _ Optional ByVal WorldName As String = "", _ Optional ForceReloadRoom As Boolean = False, Optional ForceReloadWorld As Boolean = False) 'All Together Now! If MapPosX = 0 Then MapPosX = PlayerCharacterMapPos.X If MapPosY = 0 Then MapPosY = PlayerCharacterMapPos.Y If RoomPosX = 0 Then RoomPosX = PlayerCharacterRoomPos.X If RoomPosY = 0 Then RoomPosY = PlayerCharacterRoomPos.Y If WorldName = 0 Then WorldName = THISWORLD.WorldFileName 'The default values for the position to warp to are 'your current position values If MapPosX = 0 And MapPosY = 0 And Not ForceReloadRoom Then 'You're warping to a place on the same screen. warp1 coordinate(RoomPosX, RoomPosY) ElseIf WorldName = THISWORLD.WorldFileName And Not ForceReloadWorld Then 'You're warping to a new screen in the same world. warp2 coordinate(MapPosX, MapPosY) warp1 coordinate(RoomPosX, RoomPosY) Else 'You're warping to a new world. warp3 WorldName warp2 coordinate(MapPosX, MapPosY) warp1 coordinate(RoomPosX, RoomPosY) End If End Sub

Having the routines separated like this is great for debugging purposes, and also for writing game-specific scripts.
__________________
Sell a man a fish, and he'll eat for a day. Teach the man to fish, and you're out of a job.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
RPG Maps
RPG Maps
RPG Maps RPG Maps
RPG Maps
RPG Maps
RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps RPG Maps
RPG Maps
RPG Maps
 
RPG Maps
RPG Maps
 
-->