Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def createTinimap(mapid) # new (Edit all *1 with desired scale) and yes I am aware I misspelt it
- map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
- return BitmapWrapper.new(32,32) if !map
- bitmap=BitmapWrapper.new(map.width*1,map.height*1)
- black=Color.new(0,0,0)
- tilesets=load_data("Data/Tilesets.rxdata")
- tileset=tilesets[map.tileset_id]
- return bitmap if !tileset
- helper=TileDrawingHelper.fromTileset(tileset)
- for y in 0...map.height
- for x in 0...map.width
- for z in 0..2
- id=map.data[x,y,z]
- id=0 if !id
- helper.bltSmallTile(bitmap,x*1,y*1,1,1,id) # change 1,1 to be same as scale
- end
- end
- end
- bitmap.fill_rect(0,0,bitmap.width,1,black) #get rid of these lines if you don't want the black outline
- bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black)
- bitmap.fill_rect(0,0,1,bitmap.height,black)
- bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black)
- return bitmap
- end
- def getMapSprite(id)
- if !@mapsprites[id]
- @mapsprites[id]=Sprite.new(@viewport)
- @mapsprites[id].z=0
- @mapsprites[id].bitmap=nil
- end
- if !@mapsprites[id].bitmap || @mapsprites[id].bitmap.disposed?
- @mapsprites[id].bitmap=createTinimap(id) #edited
- end
- return @mapsprites[id]
- end
- def putNeighbors(id,sprites)
- conns=@mapconns
- mapsprite=getMapSprite(id)
- dispx=mapsprite.x
- dispy=mapsprite.y
- for conn in conns
- if conn[0]==id
- b=sprites.any? {|i| i==conn[3] }
- if !b
- x=(conn[1]-conn[4])*1+dispx
- y=(conn[2]-conn[5])*1+dispy
- setMapSpritePos(conn[3],x,y)
- sprites.push(conn[3])
- putNeighbors(conn[3],sprites)
- end
- elsif conn[3]==id
- b=sprites.any? {|i| i==conn[0] }
- if !b
- x=(conn[4]-conn[1])*1+dispx # same as before, change *1 with desired scale
- y=(conn[5]-conn[2])*1+dispy
- setMapSpritePos(conn[0],x,y)
- sprites.push(conn[3])
- putNeighbors(conn[0],sprites)
- end
- end
- end
- end
- def generateConnectionData
- ret=[]
- # Create a clone of current map connection
- for conn in @mapconns
- ret.push(conn.clone)
- end
- keys=@mapsprites.keys
- return ret if keys.length<2
- # Remove all connections containing any sprites on the canvas from the array
- for i in keys
- removeOldConnections(ret,i)
- end
- # Rebuild connections
- for i in keys
- refs=getDirectConnections(keys,i)
- for refmap in refs
- othersprite=getMapSprite(i)
- refsprite=getMapSprite(refmap)
- c1=(refsprite.x-othersprite.x)/1 # you know the drill, 1 changes to your scale
- c2=(refsprite.y-othersprite.y)/1
- conn=[refmap,0,0,i,c1,c2]
- j=0;while j<ret.length && !connectionsSymmetric?(ret[j],conn)
- j+=1
- end
- if j==ret.length
- ret.push(conn)
- end
- end
- end
- return ret
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement