Page 1 of 1

InitSprite useful?

Posted: Mon Sep 04, 2017 7:12 pm
by CONVERT
Hello,

Its curious, the example code Sprite.sb found in the help file of SB 2.10 x86 works with or without InitSprite, and the help says it's needed.

Code: Select all


;
; ------------------------------------------------------------
;
;   SpiderBasic - Sprite example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

;wno_sprite = InitSprite()    ; with or without, it does not matter
;Debug Str(wno_sprite)

Debug "use arrow keys to move"

OpenScreen(800, 600, 32, "400 sprites")

Procedure RenderFrame()
  Static x, y
  
  ClearScreen(RGB(0, 0, 0))

  If ExamineKeyboard()
    
    If KeyboardPushed(#PB_Key_Left)
      x-1
    ElseIf KeyboardPushed(#PB_Key_Right)
      x+1
    EndIf
    
    If KeyboardPushed(#PB_Key_Up)
      y-1
    ElseIf KeyboardPushed(#PB_Key_Down)
      y+1
    EndIf
    
    ; Reduce the sprite size before display
    ;
    ZoomSprite(0, 60, 60)
    
    ; Display 100 sprites !
    ;
    For xDelta = 0 To 9
      For yDelta = 0 To 9 
        DisplayTransparentSprite(0, x+xDelta*60, y+yDelta*60, 128) ; half transparency
      Next
    Next
    
    ; and another 100 sprites !
    ;
    For xDelta = 0 To 9
      For yDelta = 0 To 9
        DisplaySprite(0, x*2+xDelta*60, y*2+yDelta*60)
      Next
    Next
    
  EndIf
  
  FlipBuffers() ; continue the rendering
EndProcedure


Procedure Loading(Type, Filename$)
  Static NbLoadedElements
  
  NbLoadedElements+1
  If NbLoadedElements = 1 ; Finished the loading of all images and sounds, we can start the applications
    FlipBuffers() ; start the rendering
  EndIf
EndProcedure


Procedure LoadingError(Type, Filename$)
  Debug Filename$ + ": loading error"
EndProcedure

; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
BindEvent(#PB_Event_RenderFrame, @RenderFrame())

LoadSprite(0, "Data/Spider.png")



Re: InitSprite useful?

Posted: Mon Sep 04, 2017 8:33 pm
by MrTAToad
All InitSprite does in SpiderBasic is set anti-aliasing to nearest pixel mode...

Re: InitSprite useful?

Posted: Wed Sep 06, 2017 10:37 am
by CONVERT
Thanks for reply, MrTATouad.

If I understand you, without InitSprite, there is no anti-aliasing. But, it's not visible...

"All InitSprite done in SpiderBasic is set anti-aliasing to nearest pixel mode..."

Re: InitSprite useful?

Posted: Wed Sep 06, 2017 11:08 am
by MrTAToad
The anti-aliasing is only visible for scaling, and possibly rotation.

Re: InitSprite useful?

Posted: Wed Sep 06, 2017 8:33 pm
by CONVERT
OK, thanks. I'll try.