Hi all,
some time ago, I started working on a minimap after discussing several techniques in
this thread. So far, I've made routines that use sprites, memblocks and bitmaps. Each have their pro's and cons, and I'm now looking into the possibility of scrolling and scaling a minimap-texture across a plane.
I've come up with this simple code:
`Scale&Scroll_Texture
`Scale&Scroll_Texture.dba
`======================
` set variables
` ---------------------------------------------------------
global ScreenX = 1024
global ScreenY = 768
global TotalUScroll# = 0.0
global ScrollIncrement# = 0.01
global ScaleUIncrement# = 0.01
global ScaleVIncrement# = 0.01
` set screen
` ---------------------------------------------------------
set display mode ScreenX, ScreenY, 32
Sync on
sync rate 60
autocam on
color backdrop rgb(0,0,0)
backdrop on
` load image, generate object and texture it
` ---------------------------------------------------------
load image "Scale&Scroll_image.png", 1, 1
make object plane 1, 256, 256
texture object 1, 1
position object 1,0, 0, -100
` main loop
` ---------------------------------------------------------
do
text 0, 0, "arrows: scroll texture"
text 0, 10, "+ & - : scale texture"
text 0, 30, "Fps: "+str$(screen fps())
` scroll image along object
if keystate(72) = 1
if TotalUScroll# < 1.0
scroll object texture 1, 0.0, ScrollIncrement#
inc TotalUScroll#, ScrollIncrement#
else
scroll object texture 1, 0.0, -1.0+ScrollIncrement#
dec TotalUScroll#, 1.0 - ScrollIncrement#
endif
endif
if keystate(75) = 1
if TotalUScroll# < 1.0
scroll object texture 1, ScrollIncrement#, 0.0
inc TotalUScroll#, ScrollIncrement#
else
scroll object texture 1, -1.0+ScrollIncrement#, 0.0
dec TotalUScroll#, 1.0 - ScrollIncrement#
endif
endif
if keystate(77) = 1
if TotalUScroll# < 1.0
scroll object texture 1, -ScrollIncrement#, 0.0
inc TotalUScroll#, ScrollIncrement#
else
scroll object texture 1, -1.0+ScrollIncrement#, 0.0
dec TotalUScroll#, 1.0 - ScrollIncrement#
endif
endif
if keystate(80) = 1
if TotalUScroll# < 1.0
scroll object texture 1, 0.0, -ScrollIncrement#
inc TotalUScroll#, ScrollIncrement#
else
scroll object texture 1, 0.0, -1.0+ScrollIncrement#
dec TotalUScroll#, 1.0 - ScrollIncrement#
endif
endif
` scale image across object
if keystate(78) = 1
scale object texture 1, 0, ScaleUIncrement#, ScaleVIncrement#
endif
if keystate(74) = 1
scale object texture 1, 0, -ScaleUIncrement#, -ScaleVIncrement#
endif
sync
loop
The scrolling works, but the scaling does not. I've searched the forum and read the command (once?) had a bug that prevented textures from scaling correctly. It's supposed to be fixed, so I'm guessing I'm doing something wrong myself. Can somebody point out what that is? I've added the code and image used as an attachment to this post.