Author Topic: BlitzMax RotoZoom[BMAX]  (Read 6395 times)

0 Members and 1 Guest are viewing this topic.

Offline zparticle

  • Atari ST
  • ***
  • Posts: 168
  • Karma: 11
    • View Profile
    • ScottShaver2000
BlitzMax RotoZoom[BMAX]
« on: June 13, 2006 »
A conversion of Rbraz's rotozoom from the coding competition to BlitzMax.

http://www.scottshaver2000.com/blitz/effects/rotozoom/rotozoom.exe





Code: [Select]
'=================================================================
' By: Scott Shaver
'
' This is based HEAVILY on code from Rbraz at the Dark Bit Factory
' forums. The original version was in PlitzPlus.
'=================================================================
Strict

Framework BRL.GlMax2D
Import BRL.System
Import BRL.Basic
Import BRL.Retro
Import BRL.Max2D
Import BRL.pngloader

Graphics 320,240',32',60

'=================================================================
SetMaskColor(0,0,0)
Incbin "zp-logo.png"
Global logo:TImage = LoadImage("incbin::zp-logo.png")
Global pixmap:TPixmap = LockImage(logo)

Incbin "background2.png"
Global bg:TImage = LoadImage("incbin::background2.png")


Global ang:Double=0
'=================================================================
While Not KeyHit(KEY_ESCAPE)
Cls

' draw the background
SetAlpha(1)
SetColor(255,255,255)
TileImage(bg,0,0)

' do the rotation and zoom
DoIt(pixmap,ang)

' increase the angle each frame
ang:+1
Flip
Wend
UnlockImage(logo)
End

' this is the rotozoom function
Function DoIt(pixmap:TPixmap,angle:Float)

Local osin:Double = Sin(angle)
Local sina:Float = (osin*1.5)*(osin*1.5)
Local cosa:Float = (Cos(angle)*1.5)*(osin*1.5)
Local w:Int = GraphicsWidth()
Local h:Int = GraphicsHeight()
Local iw:Int = pixmap.width'ImageWidth(image)
Local ih:Int = pixmap.height'ImageHeight(image)
Local iwh:Int = iw Shr 1
Local ihh:Int = ih Shr 1

' fill in the entire screen area
For Local x:Int = 0 Until w
For Local y:Int = 0 Until h

' find out which image pixel to read from
Local rx:Double = Abs((x * cosa - y * sina) + iwh) Mod iw
Local ry:Double = Abs((x * sina + y * cosa) + ihh) Mod ih

Local pixel:Int = pixmap.ReadPixel(rx,ry)
Local a:Float = (pixel & $FF000000) Shr 24
If a>0 Then
Local r:Float = (pixel & $00FF0000) Shr 16
Local g:Float = (pixel & $0000FF00) Shr 8
Local b:Float = (pixel & $000000FF)
SetAlpha(a/255)
SetColor(r,g,b)
Plot x,y
EndIf
Next
Next
End Function
« Last Edit: July 21, 2007 by Shockwave »

Offline asdflkj

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
Re: BlitzMax RotoZoom
« Reply #1 on: June 13, 2006 »
-
« Last Edit: August 06, 2025 by marclurr »

Offline zparticle

  • Atari ST
  • ***
  • Posts: 168
  • Karma: 11
    • View Profile
    • ScottShaver2000
Re: BlitzMax RotoZoom
« Reply #2 on: June 13, 2006 »
 ;D

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: BlitzMax RotoZoom
« Reply #3 on: June 13, 2006 »
Nice one dude!

 :cheers:
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: BlitzMax RotoZoom
« Reply #4 on: June 14, 2006 »
Nice FX ... but is it just on my machine (WinXP) that the app is still running
in the background after quitting it with ESCAPE  ???


I have to kill it manually in the task-manager ...


EDIT: I was wrong - it just happens when you press the close button
of the window
« Last Edit: June 14, 2006 by benny! »
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline zparticle

  • Atari ST
  • ***
  • Posts: 168
  • Karma: 11
    • View Profile
    • ScottShaver2000
Re: BlitzMax RotoZoom
« Reply #5 on: June 14, 2006 »
Opps sorry, you need to hit Escape to quit not the window close button.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: BlitzMax RotoZoom
« Reply #6 on: June 14, 2006 »
Ups ... you are right ... with exiting by pressing ESCAPE the programm
is really killed !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: BlitzMax RotoZoom
« Reply #7 on: June 14, 2006 »
Cool stuff, smooth too :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: BlitzMax RotoZoom
« Reply #8 on: June 14, 2006 »
@zparticle,  in you main loop you could have this "If AppTerminate() Then End" that would end the program if someone uses the X to close the application.

Offline zparticle

  • Atari ST
  • ***
  • Posts: 168
  • Karma: 11
    • View Profile
    • ScottShaver2000
Re: BlitzMax RotoZoom
« Reply #9 on: June 15, 2006 »
Thanks.  :)

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: BlitzMax RotoZoom
« Reply #10 on: June 24, 2006 »
No problem. You have done some pretty nice stuff with Bmax so far. Keep it coming, always interested in seeing what others get out of using it.