Qbasicnews.com

Full Version: Particles #3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: 16177-t.png]

Download binaries

Get Yagl here!

Code:
'#################################################################
'#
'# Yagl Playing Particles
'#
'# Author: Z!re
'# Group: Plantasy Studios
'#
'# When: 2006-Jan-12
'#
'# 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

extra = 10
fpc! = timer+1

aSurf = imagecreate(700, 700)

line aSurf, (0,0)-(699,699), RGB(255, 0, 255), BF
for a = 0 to 10000
    pset aSurf, (700*rnd, 700*rnd), RGB(255, 0, 0 )
next
line aSurf, (0,0)-(700,700), RGB(255, 0, 0 )
line aSurf, (1,0)-(701,700), RGB(255, 0, 0 )
'# Finalize before loading to Yagl by making sure the alpha channel is set. FBGFX sets it to 0 by default
for x = 0 to 699
    for y = 0 to 699
        cptr(uinteger ptr, aSurf)[1+(y*700)+x] = cptr(uinteger ptr, aSurf)[1+(y*700)+x] + &H20000000
    next
next
someSurf = YaglGfxDevice_createSurface
result = YaglGfxSurface_loadFromMemory( someSurf, aSurf+4, 700, 700, BITMAP_FORMAT_ARGB32 )

line aSurf, (0,0)-(699,699), RGB(255, 0, 255), BF
for a = 0 to 10000
    pset aSurf, (700*rnd, 700*rnd), RGB(0, 255, 0 )
next
line aSurf, (0,0)-(700,700), RGB(0, 255, 0 )
line aSurf, (1,0)-(701,700), RGB(0, 255, 0 )
'# Finalize before loading to Yagl by making sure the alpha channel is set. FBGFX sets it to 0 by default
for x = 0 to 699
    for y = 0 to 699
        cptr(uinteger ptr, aSurf)[1+(y*700)+x] = cptr(uinteger ptr, aSurf)[1+(y*700)+x] + &H20000000
    next
next
someSurf1 = YaglGfxDevice_createSurface
result = YaglGfxSurface_loadFromMemory( someSurf1, aSurf+4, 700, 700, BITMAP_FORMAT_ARGB32 )

line aSurf, (0,0)-(699,699), RGB(255, 0, 255), BF
for a = 0 to 10000
    pset aSurf, (700*rnd, 700*rnd), RGB(0, 128, 255 )
next
line aSurf, (0,0)-(700,700), RGB(0, 128, 255 )
line aSurf, (1,0)-(701,700), RGB(0, 128, 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 699
    for y = 0 to 699
        cptr(uinteger ptr, aSurf)[1+(y*700)+x] = cptr(uinteger ptr, aSurf)[1+(y*700)+x] + &H20000000
    next
next
someSurf2 = YaglGfxDevice_createSurface
result = YaglGfxSurface_loadFromMemory( someSurf2, aSurf+4, 700, 700, BITMAP_FORMAT_ARGB32 )

line aSurf, (0,0)-(699,699), RGB(255, 0, 255), BF
for a = 0 to 10000
    pset aSurf, (700*rnd, 700*rnd), RGB(255, 255, 0 )
next
line aSurf, (0,0)-(700,700), RGB(255, 255, 0 )
line aSurf, (1,0)-(701,700), RGB(255, 255, 0 )
'# Finalize before loading to Yagl by making sure the alpha channel is set. FBGFX sets it to 0 by default
for x = 0 to 699
    for y = 0 to 699
        cptr(uinteger ptr, aSurf)[1+(y*700)+x] = cptr(uinteger ptr, aSurf)[1+(y*700)+x] + &H20000000
    next
next
someSurf3 = YaglGfxDevice_createSurface
result = YaglGfxSurface_loadFromMemory( someSurf3, aSurf+4, 700, 700, BITMAP_FORMAT_ARGB32 )

imagedestroy aSurf
screen 0
print "Yagl particle demo #3"
print
print "This demo is actually constructed using 4 large bitmaps that are rotated,
print "scaled, mirrored and blended to create a particle like effect"
print "In addition, it shows how to use FBGFXLib2 and Yagl together"
print "FPS is as always locked at a maximum of 50"
print
print "-Z!re"

do
    fps += 1
    key = YaglKeyboard_getKey
    
    YaglGfxDevice_blitRotatedScaled( -100, -100, al!, 10, 10, someSurf, BLIT_ALPHAMASKED, 1.0! )
    YaglGfxDevice_blitRotatedScaled( -100, 580, al!, -10, 10, someSurf1, BLIT_ALPHAMASKED, 1.0! )
    YaglGfxDevice_blitRotatedScaled( 740, -100, al!, 10, -10, someSurf2, BLIT_ALPHAMASKED, 1.0! )
    YaglGfxDevice_blitRotatedScaled( 740, 580, al!, -10, -10, someSurf3, BLIT_ALPHAMASKED, 1.0! )
    
    al! = (al! + 0.15!)
    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 effect! More colorful to most other demos.