Draw rect

BlitzMax Forums/BlitzMax Programming/Draw rect

Czar Flavius(Posted 2010) [#1]
In my game I want a building to build by first only showing the bottom row of the image, then the next and progressively reveal the image upwards. I can do that, but when the image is finished and I move to a regular draw the image will jump to another position of the map! I've tried subtracting half the image's height (in case it's the midhandle), disabling the midhandle completely and other trial and error but I cannot get it to work right for all image sizes and it also needs to take into account scale to boot.

p is the level of build progress, from 0.0 to 1.0. The first line of the method just adds on any kind of offset there might be to an image. I'm testing on images with 0, 0 offset so it can't be the problem (pos is unchanged).

	Method draw(pos:TVec2, frame, scale:Float)
		pos = pos.Add(_pivot.Scal(scale))
		DrawImage _image, pos.x, pos.y, frame
	End Method
	
	Method draw_rect(pos:TVec2, frame, scale:Float, p:Float)
		pos = pos.Add(_pivot.Scal(scale))
		Local i = ImageHeight(_image)
		DrawSubImageRect (_image, pos.x, pos.y, i, i, 0, i-i*p, i, i, 0, i*p, frame)
	End Method



Czar Flavius(Posted 2010) [#2]
Fixed it. Not the right number was sent as the scale parameter.