Main Menu

Loading image 1 into map

Started by dangerousbrian, July 06, 2005, 12:11:44 PM

Previous topic - Next topic

dangerousbrian

For the last couple of days I've been trying to use the mapping commands & getting nowhere! I've drawn a 28x28 image to use as a block and I just can't load it into a map. (i'm trying to do this using the GetMapBlk command, is that right?)

kevin

#1
That's one way.   Before you can grab blocks like that though, you need to have created provision for the map to have blocks.   After doing this, the map will have a list of block ready to grab like above.

PlayBASIC Code: [Select]
   ; Set Width & Height variables of the Map tiles
TileWidth=16
Tileheight=16

; Get a free Map index
MyMap=GetFreeMap()

; Create a map with provision for 5 levels
CreateMap MyMap,5

; Create some empty graphics blocks for MyMAP
CreateMapGFX MyMap,TileWidth,TileHeight,10,RGB(0,0,0)

For lp=1 To 10
; draw a randomly coloured box
BoxC 0,0,TileWidth-1,TileHeight-1,1,RndRGB()
; Copy the box image into MyMap
GetMapBlk MyMap, lp, 0,0
Next

; Draw the created blocks to the Screen
For lp =0 To GetMapBlocks(MyMap)
DrawMapBlk MyMap,lp,lp*TileWidth,100,0
Next

; Display the screen and wait for a key press
Sync
WaitKey




dangerousbrian

Thank Kevin, I've been practising doing that for a couple of days (and it works), but now I've drawn my tile, loaded it into the media manager, loaded it into the program, I still can't see how to get it to replace the coloured blocks....

kevin

#3
 if you load the Block Sheet image (a picture with a bunch of tiles on it)

you'd change it something like this..


PlayBASIC Code: [Select]
 Set Width & Height variables of the Map tiles
TileWidth=16
Tileheight=16

; Get a free Map index
MyMap=GetFreeMap()

; Create a map with provision for 5 levels
CreateMap MyMap,5

; Create some empty graphics blocks for MyMAP
CreateMapGFX MyMap,TileWidth,TileHeight,10,RGB(0,0,0)


; load your Block sheet into memory
LoadImage "MyBlockSheetIMage.bmp",50

; redirect all drawing/grabbing to this image
RenderToIMage 50

; grab 10 blocks from this image
x=0
For lp=1 To 10
; Copy this blockinto MyMap
GetMapBlk MyMap, lp, x,0
; move the X position across to the next block coordinate
x=x+width
Next

; Tell PB to now draw/grab to the screen
rendertoscreen



; Draw the created blocks to the Screen
For lp =0 To GetMapBlocks(MyMap)
DrawMapBlk MyMap,lp,lp*TileWidth,100,0
Next

; Display the screen and wait for a key press
Sync
WaitKey







 Just make sure the grab block loop never attempts to grab a block off the edge of your Block sheet..


dangerousbrian

thanks Kevin, I'm experimenting with this........ I'd drawn a small block for the map, intending to repeat it ad nausea, should I have drawn the whole picture (800x600) and grabbed blocks from it?

dangerousbrian

Still can't work it out! Never mind, PB is so quick It's allowed me to load entire pics of background scenery & scroll them at the appropriate time with no obvious loss of performance :) !

kevin

can you post tile gfx so I canl have a quick go and throwing an working example together ?

dangerousbrian

That's very kind! Will post gfx asap. (Can't do it now, I'm 30mins away from starting a show..)

dangerousbrian

#8
Sorry Kevin, I don't know how to put my tile in here (tried pasting it in, but that didn't work) :(

So you can see what I've achieved so far, and why I'm not too bothered about about getting the mapping right on this particular game, (Although I must get to grips with it for future races) I've sent you it to your hotmail address. I don't want to publish it on the internet as I don't want to give it away (or even sell it!) to other pub presenters

Draco9898

#9
Brian, use Imageshack: (login required)

then copy the URL and paste it here in between two "[/img]" tags, then we'll see your pic
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

dangerousbrian


Draco
This wasn't the tile I was originally trying to use,but it gives a far better effect than the one I created (If I could make it work!) Many thanks for your help Draco

kevin

#11
If you only have one image, it's prolly best you use the TileImage command

PlayBASIC Code: [Select]
 loadImage "MyImage.bmp",1

TileIMage 1,0,0,0
Sync
Waitkey




dangerousbrian

I'm obviously clueless on this subject! Should I have posted the huge picture (about 6400x600 pixels)?
Because I'm struggling with this I've been playing about with the visual effect you get when you increase the speed of closer objects flying across the screen, while things further back move more slowly. I've got four 'layers' working now & it looks quite realistic (for cartoon graphics!)