Is this possible

Blitz3D Forums/Blitz3D Programming/Is this possible

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.







This may or may not help. :) I need to work out this kind of thing for another project so I wipped this up to show how you might be able to do this sort of thing with sprites.

Block.Jpg Pic:


Heres the code:

;Pixel perfect sprite
;Copyright (c) 2004 Richard R Betson 
;www.redeyeware.50megs.com
;USE - Free to all

;09/15/04


Graphics3D 800,600,16,2

sprt=LoadSprite("block.jpg",4)
EntityFX sprt,1



source_w=128
source_h=128

;Pixel width and height (64 appears to = 1 Blitz3D unit)
rect_w=64
rect_h=64


Dim sprite(50)
Dim sprite_x(50)
Dim sprite_y(50)


;Globals for ScaleToPixel Function
Global w#
Global h#

;Given the 
ScaleToPixel(rect_w,rect_h,source_w,source_h)



For i=1 To 35
	
	
	sprite(i)=CopyEntity(sprt)
	EntityColor sprite(i),Rnd(128)+128,Rnd(128)+128,Rnd(128)+128
	sprite_x(i)=i*rect_w
	sprite_y(i)=i*rect_h

	ScaleSprite sprite(i),w#,h#
Next
i=0

FreeEntity sprt



cam=CreateCamera()
PositionEntity cam,0,0,-4
PointEntity cam,sprite(1)




While Not KeyHit(1)

	For y= 0 To 4
		
		For x=0 To 6
			i=i+1
			PositionEntity sprite(i),x-3,y-2,0
		Next
	Next
	i=0
	UpdateWorld
	RenderWorld
	
	Flip
Wend



;Returns the proper scale to match a pixel width and height. source_w/source_h are the actual image size
Function ScaleToPixel(rect_w,rect_h,source_w,source_h)

	w#=( Float(rect_w)/Float(source_w) )
	h#=( Float(rect_h)/Float(source_h) )

End Function