ZoomSprite() without Sprite3D

Share your advanced PureBasic knowledge/code with the community.
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

ZoomSprite() without Sprite3D

Post by J. Baker »

Here's the procedure and an example to download. ;)

DOWNLOAD EXAMPLE

Code: Select all

Structure ZoomSpriteCalculations
  SavedSpriteWidth.f
  SavedSpriteHeight.f
  SaveData.l
EndStructure

Procedure ZoomSprite(Sprite, SpriteWidth.f, SpriteHeight.f)

  Static Dim SpriteZoom.ZoomSpriteCalculations(99)
  
  If SpriteZoom(Sprite)\SaveData = 0
    
      SpriteZoom(Sprite)\SavedSpriteWidth = SpriteWidth
      SpriteZoom(Sprite)\SavedSpriteHeight = SpriteHeight
      
       CreateSprite(Sprite, SpriteWidth, SpriteHeight)
  
        StartDrawing(SpriteOutput(Sprite))
          DrawImage(ImageID(Sprite), 0, 0, SpriteWidth, SpriteHeight)
         StopDrawing()
          
       SpriteZoom(Sprite)\SaveData = 1
  EndIf
  
  If SpriteZoom(Sprite)\SavedSpriteWidth <> SpriteWidth Or SpriteZoom(Sprite)\SavedSpriteHeight <> SpriteHeight
    SpriteZoom(Sprite)\SaveData = 0
  EndIf
  
EndProcedure
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: ZoomSprite() without Sprite3D

Post by J. Baker »

If you are using windows, I just noticed Library Subsystem: DirectX7 gives better results when zooming.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ZoomSprite() without Sprite3D

Post by STARGÅTE »

Not a good trick / tip.
The procedure is much too slow for the application.
The procedure works only with sprite numbers 0-99 ... and there is no check whether sprite is within a range of 0-99
but many use random numbers with #PB_Any
why you not use a Map like SpriteZoom(Str(Sprite))?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: ZoomSprite() without Sprite3D

Post by J. Baker »

STARGÅTE wrote:Not a good trick / tip.
The procedure is much too slow for the application.
The procedure works only with sprite numbers 0-99 ... and there is no check whether sprite is within a range of 0-99
but many use random numbers with #PB_Any
why you not use a Map like SpriteZoom(Str(Sprite))?
I simply showed that it can be done. You are welcome to do with it how ever you want. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply