Drawing map to a surface other than the screen

Started by monkeybot, January 26, 2014, 06:10:18 AM

Previous topic - Next topic

monkeybot

Can you do this?


in theory the below code should render to the temp image and then scroll the temp image to the right


PlayBASIC Code: [Select]
; ---------------------------------------------------------------------

MyMap = NewMap(1)

TileWidth=64
TileHeight=64
Number_of_tiles = 5
For lp=1 To Number_of_tiles
xpos=lp*tileWidth
BoxC Xpos,0,Xpos+TileWidth,TileHeight,1,RndRGB()
text Xpos,0,"Block:"+Str$(lp)
Next
TempImage=GetFreeImage()
GetImage TempImage,0,0,xpos+TIleWidth,Tileheight
MakeMapGFX MyMAP,TempImage,TileWidth,TileHeight,Number_Of_Tiles,RGB(0,0,0)
DeleteImage TempImage
MyLevel= NewLevel(MyMap,100,200)
For Ylp=0 To GetLevelHeight(mymap,MyLevel)-1
For Xlp=0 To GetLevelWidth(MyMap,MyLevel)-1
PokeLevelTile MyMap,MyLevel,Xlp,ylp,Rnd(Number_of_tiles-1)
Next xlp
Next ylp





;i added these lines



local tempx=newfximage(1000,1000)
rendertoimage tempx





DrawMap MyMap,MyLevel,0,100
cls
local q=0

rendertoscreen
do
wait 10
drawimage tempx,q,0,1
q++
Sync
loop
end





kevin



I really don't think you want to do this ?

PlayBASIC Code: [Select]
  local tempx=newfximage(1000,1000)
rendertoimage tempx

; draw may to the surface
DrawMap MyMap,MyLevel,0,100

; now lets clear that surface .. erm :)
cls
local q=0

rendertoscreen


monkeybot

#2
oops oh yeah,doh!


i got rid of the cls and it still doesn't work...


PlayBASIC Code: [Select]
       MyMap = NewMap(1)

TileWidth=64
TileHeight=64
Number_of_tiles = 5
For lp=1 To Number_of_tiles
xpos=lp*tileWidth
BoxC Xpos,0,Xpos+TileWidth,TileHeight,1,RndRGB()
text Xpos,0,"Block:"+Str$(lp)
Next
TempImage=GetFreeImage()
GetImage TempImage,0,0,xpos+TIleWidth,Tileheight
MakeMapGFX MyMAP,TempImage,TileWidth,TileHeight,Number_Of_Tiles,RGB(0,0,0)
DeleteImage TempImage
MyLevel= NewLevel(MyMap,100,200)
For Ylp=0 To GetLevelHeight(mymap,MyLevel)-1
For Xlp=0 To GetLevelWidth(MyMap,MyLevel)-1
PokeLevelTile MyMap,MyLevel,Xlp,ylp,Rnd(Number_of_tiles-1)
Next xlp
Next ylp





;i added these line so you shouldn't be able to see the image until tempx is drawn



local tempx=newfximage(1000,1000)
;cls
rendertoimage tempx





DrawMap MyMap,MyLevel,0,0
;cls
local q=0

rendertoscreen
do
;wait 10
drawimage tempx,q,100,1
q++
Sync
loop
end




kevin

 Looks like you're drawing Video blocks to an FX image..  not a good idea !



      MakeMapGFX MyMAP,TempImage,TileWidth,TileHeight,Number_Of_Tiles,RGB(0,0,0),2 = format of map blocks

monkeybot

#4
that listing was lifted from the help files in the maps tutorial
i have changed that to 2
i have also changed the temp image to an fx



***SOLVED***

i was using your playmapper loader and CreateMapGFX was defaulting to 1 ,so i changed type to 2 and hey presto!!!

Thanks