InitSprite useful?

Just starting out? Need help? Post your questions and find answers here.
CONVERT
Posts: 7
Joined: Thu Aug 24, 2017 7:43 am

InitSprite useful?

Post 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")


SpiderBasic 2.10 x86 Full version, Windows 10 home 32.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: InitSprite useful?

Post by MrTAToad »

All InitSprite does in SpiderBasic is set anti-aliasing to nearest pixel mode...
CONVERT
Posts: 7
Joined: Thu Aug 24, 2017 7:43 am

Re: InitSprite useful?

Post 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..."
SpiderBasic 2.10 x86 Full version, Windows 10 home 32.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: InitSprite useful?

Post by MrTAToad »

The anti-aliasing is only visible for scaling, and possibly rotation.
CONVERT
Posts: 7
Joined: Thu Aug 24, 2017 7:43 am

Re: InitSprite useful?

Post by CONVERT »

OK, thanks. I'll try.
SpiderBasic 2.10 x86 Full version, Windows 10 home 32.
Post Reply