- 1,189
- Posts
- 11
- Years
- Omnipresence
- Seen Aug 8, 2023
Trying to create a region map that displays some specific locations, via just x,y coordinates. I'm not exactly sure how it works. What I've gotten so far
It displays the map itself fine, but it just tells me the area is unknown for the locations. Not really sure how the locations work exactly, just bumbling around, so any pointers would be great.
Spoiler:
Code:
################################################################################
# Shows the Quest map.
################################################################################
class PokemonQuestMapScene
def pbStartScene(quest,regionmap=-1)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites={}
pbRgssOpen("Data/townmap.dat","rb"){|f|
@mapdata=Marshal.load(f)
}
mappos=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapPosition)
region=regionmap
if region<0 # Use player's current region
region=mappos ? mappos[0] : 0 # Region 0 default
end
@sprites["background"]=IconSprite.new(0,0,@viewport)
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/mapbg"))
@sprites["map"]=IconSprite.new(0,0,@viewport)
@sprites["map"].setBitmap("Graphics/Pictures/#{@mapdata[region][1]}")
@sprites["map"].x+=(Graphics.width-@sprites["map"].bitmap.width)/2
@sprites["map"].y+=(Graphics.height-@sprites["map"].bitmap.height)/2
for hidden in REGIONMAPEXTRAS
if hidden[0]==region && hidden[1]>0 && $game_switches[hidden[1]]
if !@sprites["map2"]
@sprites["map2"]=BitmapSprite.new(480,320,@viewport)
@sprites["map2"].x=@sprites["map"].x; @sprites["map2"].y=@sprites["map"].y
end
pbDrawImagePositions(@sprites["map2"].bitmap,[
["Graphics/Pictures/#{hidden[4]}",
hidden[2]*PokemonRegionMapScene::SQUAREWIDTH,
hidden[3]*PokemonRegionMapScene::SQUAREHEIGHT,0,0,-1,-1]
])
end
end
@point=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT+4)
@point.fill_rect(0,0,
PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
@point2=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT+4)
@point2.fill_rect(4,0,
PokemonRegionMapScene::SQUAREWIDTH,
PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
@point3=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT+4)
@point3.fill_rect(0,4,
PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
@point4=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
PokemonRegionMapScene::SQUAREHEIGHT+4)
@point4.fill_rect(4,4,
PokemonRegionMapScene::SQUAREWIDTH,
PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
mapx=quest[8][0]
mapy=quest[8][1]
hidden=$game_quests.isHidden?(quest[0])
points=[]
if quest[10]==region && quest[8][0]>=0 && quest[8][1]>=0
mapwidth=1+PokemonRegionMapScene::RIGHT-PokemonRegionMapScene::LEFT
if !hidden
mapsize=pbGetMetadata(enc,MetadataMapSize)
if mapsize && mapsize[0] && mapsize[0]>0
sqwidth=mapsize[0]
sqheight=(mapsize[1].length*1.0/mapsize[0]).ceil
for i in 0...sqwidth
for j in 0...sqheight
if mapsize[1][i+j*sqwidth,1].to_i>0
points[mapx+i+(mapy+j)*mapwidth]=true
end
end
end
else
points[mapx+mapy*mapwidth]=true
end
end
end
i=0
for j in 0...points.length
if points[j]
s=SpriteWrapper.new(@viewport)
s.x=(j%mapwidth)*PokemonRegionMapScene::SQUAREWIDTH-2
s.x+=(Graphics.width-@sprites["map"].bitmap.width)/2
s.y=(j/mapwidth)*PokemonRegionMapScene::SQUAREHEIGHT-2
s.y+=(Graphics.height-@sprites["map"].bitmap.height)/2
if j>=1 && points[j-1]
if j>=mapwidth && points[j-mapwidth]
s.bitmap=@point4
else
s.bitmap=@point2
end
else
if j>=mapwidth && points[j-mapwidth]
s.bitmap=@point3
else
s.bitmap=@point
end
end
@sprites["point#{i}"]=s
i+=1
end
end
@numpoints=i
@sprites["mapbottom"]=MapBottomSprite.new(@viewport)
@sprites["mapbottom"].maplocation=pbGetMessage(MessageTypes::RegionNames,region)
@sprites["mapbottom"].mapdetails=_INTL("{1}'s location",quest[1])
if points.length==0
@sprites["mapbottom"].nonests=true
end
return true
end
def pbUpdate
@numpoints.times {|i|
@sprites["point#{i}"].opacity=[64,96,128,160,128,96][(Graphics.frame_count/4)%6]
}
end
def pbMapScene(listlimits)
Graphics.transition
ret=0
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::B)
ret=1
pbPlayCancelSE()
pbFadeOutAndHide(@sprites)
break
end
end
return ret
end
def pbEndScene
pbDisposeSpriteHash(@sprites)
@point.dispose
@viewport.dispose
end
end
class PokemonQuestMap
def initialize(scene)
@scene=scene
end
def pbStartScreen(quest,region,listlimits)
@scene.pbStartScene(quest,region)
[email protected](listlimits)
@scene.pbEndScene
return ret
end
end
It displays the map itself fine, but it just tells me the area is unknown for the locations. Not really sure how the locations work exactly, just bumbling around, so any pointers would be great.