News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

cant do gfx now!

Started by RaverDave, January 27, 2011, 12:11:13 AM

Previous topic - Next topic

RaverDave

hmm..stuck again! I was hoping to make a spaceinvaders sprite out of data statements...
but for some reason it is garbage!



; PROJECT : spaceinvaders
; AUTHOR  : david wheeler
; CREATED : 27/01/2011
; EDITED  : 27/01/2011
; ---------------------------------------------------------------------
OpenScreen 640,480,32,2
SetFPS 60
ScreenVsync On
Mouse Off

global quit=false
global invader=1
creategfx()

repeat
cls 0
drawimage 1,200,200,1
check_keys()
sync
until quit=true

function check_keys()
v=ScanCode()
  print v


If v=16
  quit=true
EndIf
endfunction

Function creategfx()
CreateImage invader,15,15
RenderToImage invader
for x=0 to 12
for y=0 to 9
p=readdata()
Ink rgb(0,255,0)
if p>0
dot x,y
endif
next
next
   ScaleImage invader,52,40,1
RenderToScreen
EndFunction
data 0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,1,0,0,0,0,0,1,0,0,0
data 0,0,0,0,1,0,0,0,1,0,0,0,0
data 0,0,0,1,1,1,1,1,1,1,0,0,0
data 0,0,1,1,0,1,1,0,0,1,1,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0




Indeed trying some old code from back a few years ago..something has changed coz i get the same problem..

kevin


The problem is that your 2d loops to read the pixels are back to front.



RaverDave

I had tried a few ways before ! posting .. same results..
My old post 'hard codin all the way' used to work also but now has unexpected results

kevin

#3
 erm, how do you expect this work ?  The data is formatted is rows and you're reading it in columns.

So this..

PlayBASIC Code: [Select]
   for x=0 to 12
for y=0 to 9
p=readdata()
Ink rgb(0,255,0)
if p>0
dot x,y
endif
next
next




Should be this..

PlayBASIC Code: [Select]
   for y=0 to 9     
for x=0 to 12
p=readdata()
Ink rgb(0,255,0)
if p>0
dot x,y
endif
next
next





RaverDave

damnit! i think i was used to say
for x=1 to 12