Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CardMap
- def initialize(id)
- @id = id
- @map1 = load_data(sprintf("Data/Map%03d.rxdata",$game_map.map_id)) rescue nil
- @map1_height = @map1.height
- @map1_width = @map1.width
- @map2 = load_data(sprintf("Data/Map%03d.rxdata",id)) rescue nil
- @map2_height = @map2.height
- @map2_width = @map2.width
- end
- def pbStartScene
- @sprites={}
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @sprites["map1"]=Sprite.new(@viewport)
- @sprites["map1"].bitmap=createNormalMap($game_map.map_id)
- @sprites["map1"].z=0
- @sprites["map2"]=Sprite.new(@viewport)
- @sprites["map2"].bitmap=createNormalMap(@id)
- @sprites["map2"].z=0
- #filename="Graphics/Charactes/"+$game_player.character_name
- @direction = $game_player.direction
- @sprites["character"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
- charwidth=@sprites["character"].bitmap.width
- charheight=@sprites["character"].bitmap.height
- playerw = charwidth/4
- playerh = charheight/4
- @sprites["character"].x = $game_player.x * 32 - 16
- @sprites["character"].y = $game_player.y * 32
- if @direction == 6 #right
- @sprites["character"].x += 32*($PokemonGlobal.leftSpawn+1)
- @sprites["character"].y -= 32
- @sprites["character"].src_rect = Rect.new(0,playerh*2,charwidth/4,charheight/4)
- @sprites["map1"].x=0
- @sprites["map1"].y=0
- @sprites["map2"].x=@map2_width*32
- @sprites["map2"].y=0
- elsif @direction == 4 #left
- @sprites["character"].x -= 32*($PokemonGlobal.rightSpawn+1)
- @sprites["character"].y -= 32
- @sprites["character"].src_rect = Rect.new(0,playerh,charwidth/4,charheight/4)
- @sprites["map1"].x=0
- @sprites["map1"].y=0
- @sprites["map2"].x=-@map2_width*32
- @sprites["map2"].y=0
- elsif @direction == 2 #bottom
- #@sprites["character"].y += 32*3
- @sprites["character"].y = 15*32 - 32*($PokemonGlobal.topSpawn+1)
- @sprites["character"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
- @sprites["map1"].x=0
- @sprites["map1"].y=-(@map1_height-15)*32
- @sprites["map2"].x=0
- @sprites["map2"].y=@map2_height*32
- elsif @direction == 8 #top
- @sprites["character"].y -= 32*($PokemonGlobal.bottomSpawn+2)
- @sprites["character"].src_rect = Rect.new(0,playerh*3,charwidth/4,charheight/4)
- @sprites["map1"].x=0
- @sprites["map1"].y=0
- @sprites["map2"].x=0
- @sprites["map2"].y=-@map2_height*32
- end
- end
- def pbEndScene # CUANDO TERMINA...
- pbTeleport(@id)
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose if @viewport
- pbResetLocalSwitches
- $game_map.refresh
- end
- def pbUpdate
- tileSize = 16
- Graphics.update
- #sleep(0.02)
- if @direction == 6 || @direction == 4
- loops = 21*2
- else
- loops = 15*2
- end
- for i in 0...loops
- if @direction == 6
- @sprites["map1"].x-=tileSize
- @sprites["map2"].x-=tileSize
- @sprites["character"].x-=tileSize
- elsif @direction == 4
- @sprites["map1"].x+=tileSize
- @sprites["map2"].x+=tileSize
- @sprites["character"].x+=tileSize
- elsif @direction == 2
- @sprites["map1"].y-=tileSize
- @sprites["map2"].y-=tileSize
- @sprites["character"].y-=tileSize
- elsif @direction == 8
- @sprites["map1"].y+=tileSize
- @sprites["map2"].y+=tileSize
- @sprites["character"].y+=tileSize
- end
- Graphics.update
- #sleep(0.02)
- end
- end
- ################
- end #CIERRA LA CLASE
- class CardMapScene
- def initialize(scene)
- @scene=scene
- end
- def pbStartScreen
- @scene.pbStartScene
- @scene.pbUpdate
- @scene.pbEndScene
- end
- end
- def pbCardMapDisplay(id)
- pbResetLocalSwitches
- scene=CardMap.new(id)
- screen=CardMapScene.new(scene)
- screen.pbStartScreen
- end
- def createNormalMap(mapid)
- map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
- return BitmapWrapper.new(32,32) if !map
- bitmap=Bitmap.new(map.width*32,map.height*32)
- 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.bltTile(bitmap,x*32,(y*32),id)
- end
- end
- end
- events = []
- for i in map.events.keys
- events.push(map.events[i])
- end
- doors_lr = AnimatedBitmap.new("Graphics/Characters/doors_left_right.png")
- doors_ud = AnimatedBitmap.new("Graphics/Characters/doors_up_down.png")
- no_doors_lr = AnimatedBitmap.new("Graphics/Characters/no_doors_left_right.png")
- no_doors_ud = AnimatedBitmap.new("Graphics/Characters/no_doors_up_down.png")
- for event in events
- if(event.name.include?("DOOR"))
- if event.name.include?("Hall")
- if event.x == 1
- bitmap.blt(event.x*32,event.y*32-12,no_doors_lr.bitmap,Rect.new(32,0,32,44))
- elsif event.x == 19
- bitmap.blt(event.x*32,event.y*32-12,no_doors_lr.bitmap,Rect.new(0,0,32,44))
- elsif event.y == 1
- bitmap.blt(event.x*32-6,event.y*32+2,no_doors_ud.bitmap,Rect.new(0,0,44,30))
- elsif event.y == 13
- bitmap.blt(event.x*32-6,event.y*32+2,no_doors_ud.bitmap,Rect.new(44,0,44,30))
- end
- else
- if event.x == 1
- bitmap.blt(event.x*32,event.y*32-12,doors_lr.bitmap,Rect.new(32,0,32,44))
- elsif event.x == 19
- bitmap.blt(event.x*32,event.y*32-12,doors_lr.bitmap,Rect.new(0,0,32,44))
- elsif event.y == 1
- bitmap.blt(event.x*32-6,event.y*32+2,doors_ud.bitmap,Rect.new(0,0,44,30))
- elsif event.y == 13
- bitmap.blt(event.x*32-6,event.y*32+2,doors_ud.bitmap,Rect.new(44,0,44,30))
- end
- end
- end
- end
- #bitmap.fill_rect(0,0,bitmap.width,1,black)
- #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 pbTeleport(id)
- map=load_data(sprintf("Data/Map%03d.rxdata",id)) rescue nil
- $PokemonGlobal.escaped = false
- $PokemonGlobal.visitedrooms += 1
- $PokemonGlobal.oldmap = $game_map.map_id
- #$MapFactory.setup(id)
- $game_temp.player_new_map_id=id
- direction = $game_player.direction
- if direction == 6 #right
- $game_temp.player_new_x=$PokemonGlobal.leftSpawn
- $game_temp.player_new_y=$game_player.y
- #$game_player.moveto(2,$game_player.y)
- elsif direction == 4 #left
- $game_temp.player_new_x= map.width-1-$PokemonGlobal.rightSpawn
- $game_temp.player_new_y=$game_player.y
- #$game_player.moveto(18,$game_player.y)
- elsif direction == 2 #bottom
- $game_temp.player_new_x=$game_player.x
- $game_temp.player_new_y=$PokemonGlobal.topSpawn
- #$game_player.moveto($game_player.x,2)
- elsif direction == 8 #top
- $game_temp.player_new_x=$game_player.x
- $game_temp.player_new_y=map.height-1-$PokemonGlobal.bottomSpawn
- #$game_player.moveto($game_player.x,12)
- end
- $game_temp.player_new_direction = direction
- $scene.transfer_player
- end
- def pbSetTeleports(top, right, bottom, left)
- $PokemonGlobal.topMap = top
- $PokemonGlobal.rightMap = right
- $PokemonGlobal.bottomMap = bottom
- $PokemonGlobal.leftMap = left
- end
- def pbSetTriggers(top, right, bottom, left)
- $PokemonGlobal.topTrigger = top
- $PokemonGlobal.rightTrigger = right
- $PokemonGlobal.bottomTrigger = bottom
- $PokemonGlobal.leftTrigger = left
- end
- def pbSetSpawns(top, right, bottom, left)
- $PokemonGlobal.topSpawn = top
- $PokemonGlobal.rightSpawn = right
- $PokemonGlobal.bottomSpawn = bottom
- $PokemonGlobal.leftSpawn = left
- end
- def pbHideEvents()
- for event in $game_map.events
- event[1].character_name = ""
- end
- $game_map.refresh
- end
- def getPlayerPos
- p 'X: '+$game_player.x.to_s
- p 'Y: '+$game_player.y.to_s
- p 'bottom: '+$PokemonGlobal.bottomMap.to_s
- p $game_map.height
- end
- =begin
- Events.onStepTaken+=proc{
- if($game_player.x == $PokemonGlobal.leftTrigger && $game_player.direction == 4)
- if($PokemonGlobal.leftMap != -1)
- pbCardMapDisplay($PokemonGlobal.leftMap)
- end
- end
- if($game_player.x == ($game_map.width-1-$PokemonGlobal.rightTrigger) && $game_player.direction == 6)
- if($PokemonGlobal.rightMap != -1)
- pbCardMapDisplay($PokemonGlobal.rightMap)
- end
- end
- if($game_player.y == $PokemonGlobal.topTrigger && $game_player.direction == 8)
- if($PokemonGlobal.topMap != -1)
- pbCardMapDisplay($PokemonGlobal.topMap)
- end
- end
- if($game_player.y == ($game_map.height-1-$PokemonGlobal.bottomTrigger) && $game_player.direction == 2)
- if($PokemonGlobal.bottomMap != -1)
- pbCardMapDisplay($PokemonGlobal.bottomMap)
- end
- end
- }
- =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement