Qbasicnews.com

Full Version: Come closer, Yagl demo 4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: 16194-t.png]

Download binaries

Get Yagl here!

Code:
'#################################################################
'#
'# Yagl demo, come closer, gather around
'#
'# Author: Z!re
'# Group: Plantasy Studios
'#
'# When: 2006-Jan-13
'#
'# For: Marzec's awesome Yagl
'#
'# Copyright: Do whatever you want, it's an example, use/abuse
'#
'#################################################################

#include "yaglwrapper.bi"

randomize timer

YaglGfxDevice_setScreenMode(640, 480, 32, 0)
screenres 100, 100, 32, , -1

dim someSurf as YaglGfxSurface
dim aSurf as ubyte ptr

fpc! = timer+1

aSurf = imagecreate(100, 100)
line aSurf, (0,0)-(99,99), RGB(255, 0, 255), BF
circle aSurf, ( 50, 50 ), 40, RGB(0, 255, 255)
circle aSurf, ( 50, 50 ), 30, RGB(255, 255, 0)
circle aSurf, ( 50, 50 ), 20, RGB(255, 0, 0)
circle aSurf, ( 50, 50 ), 10, RGB(0, 0, 255)
'# Finalize before loading to Yagl by making sure the alpha channel is set. FBGFX sets it to 0 by default
for x = 0 to 99
    for y = 0 to 99
        cptr(uinteger ptr, aSurf)[1+(y*100)+x] = cptr(uinteger ptr, aSurf)[1+(y*100)+x] + &H10000000
    next
next
someSurf = YaglGfxDevice_createSurface
result = YaglGfxSurface_loadFromMemory( someSurf, aSurf+4, 100, 100, BITMAP_FORMAT_ARGB32 )

imagedestroy aSurf
screen 0

YaglGfxDevice_clear(0)
YaglGfxDevice_swapBuffers
YaglGfxDevice_clear(0)
YaglGfxDevice_swapBuffers

bp = 1
do
    fps += 1
    key = YaglKeyboard_getKey
    
    YaglGfxDevice_solidBox( 0,0, 640, 480, 0, 0.75! )
    
    for a = 0 to 8 step 4
        YaglGfxDevice_blitRotatedScaled( 320, 240, al!, (a+1), (a+1), someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, 360-al!, (a+2), (a+2), someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (180+al!) mod 360, (a+3), (a+3), someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (240+al!) mod 360, (a+4), (a+4), someSurf, BLIT_ALPHAMASKED, 1.0! )
    next
    for a = 0 to 8 step 4
        YaglGfxDevice_blitRotatedScaled( 320, 240, al!, a+4, a+1, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, 360-al!, a+3, a+2, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (180+al!) mod 360, a+2, a+3, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (240+al!) mod 360, a+1, a+4, someSurf, BLIT_ALPHAMASKED, 1.0! )
    next
    for a = 0 to 8 step 4
        YaglGfxDevice_blitRotatedScaled( 320, 240, al!, a+1, a+4, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, 360-al!, a+2, a+3, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (180+al!) mod 360, a+3, a+2, someSurf, BLIT_ALPHAMASKED, 1.0! )
        YaglGfxDevice_blitRotatedScaled( 320, 240, (240+al!) mod 360, a+4, a+1, someSurf, BLIT_ALPHAMASKED, 1.0! )
    next
    
    b += bp
    if b >= 64 then bp = -1
    if b <= -64 then bp = 1
    
    al! = (al! + 1)
    if al! >= 360! then al! -= 360!
    
    YaglGfxDevice_swapBuffers
    if timer >= fpc! then
        fpc! = timer+1
        YaglGfxDevice_setWindowTitle "FPS: "& fps &"/50"
        fps = 0
    end if
    
    sleep 20
    
loop until key = YAGL_KEY_ESCAPE
Very cool.
me likey demo