GLBasic forum

Codesnippets => 2D-snippets => Topic started by: Brick Redux on 2013-Aug-05

Title: Sprite patterns
Post by: Brick Redux on 2013-Aug-05
The code below displays patterns using zoomedsprites.  Might be halpful with demos or something as a few weeks back I was watching some progs created on the old ORIC computer.  One was a tunnel effect and it quickly came to me that my first attempt at swarming sprites (aka a galaxian/spacehawk Im coding) could duplicate this.  Its wierd how your coding always seems to tie into something else and the next day after a long sleep you nail the the idea and recreate a past effect.

Its just for fun. Press a key for a new pattern.

Code (glbasic) Select

SETCURRENTDIR("Media")

LOADSPRITE "bob.png",0
LOADSPRITE "bob1.png",1

that=40 ; that_too=40 ; factor=.5

WHILE TRUE

xx=320 ; yy=220 ; rx=10 ; ry=10 ; zoom=1 // Start in the centre.

FOR b=0 TO 30 // 30 times per loop.

FOR a=0 TO 359 STEP that

INC ang,that_too // This dictates the change in angle for this rotosprite.

Sprite_Path(image,xx,yy,rx,ry,ang,1,zoom)

INC image ; IF image>1 THEN image=0 // Flip between sprite 0 and 1.

NEXT

INC ang,this_too // Alter the settings for the next part of the B Loop.
INC zoom,factor
INC rx,b*2
INC ry,b*2

NEXT

SHOWSCREEN

KEYWAIT

that=RND(100) // Create a new pattern with random settings.
that_too=RND(100)

WEND

/// Early curbed path function i coded . It can roto move a sprite around an oval shape but isnt perfect. 
/// Created originally to display a galaxian swarm type affect for my current project.  Have found its
/// better to use DrawSprite and follow a DATA path when moving swarms - then jump them into their x/y
/// positions smoothly.
/// It can be used though to create "crummy" looking tunnel/vortex displays - hence this post.

/// Sprite_Path : sprite image, xpos,ypos,radiusx,radiusy,angle,direction,zoomsize

FUNCTION Sprite_Path: im%,x%,y%,rx%,ry%,deg%,dir%,size%

SMOOTHSHADING FALSE

IF dir>0

ROTOZOOMSPRITE im,rx * -SIN(deg) + x, ry * -COS(deg) + y, deg,size

INC deg

ELSEIF dir=-1

ROTOZOOMSPRITE im,rx * SIN(deg) + x, ry * COS(deg) + y, deg,size

DEC deg

ENDIF

ENDFUNCTION




Add the sprites to your media folder.

Enjoy.
Title: Re: Sprite patterns
Post by: Brick Redux on 2013-Aug-05
A tweak.
Title: Re: Sprite patterns
Post by: Brick Redux on 2013-Aug-05
Another.
Title: Re: Sprite patterns
Post by: Brick Redux on 2013-Aug-05
...
Title: Re: Sprite patterns
Post by: mentalthink on 2013-Aug-05
This it's really cool, I think for demos or something linked whit music can be intersting, make a videoDJ or for audio-artist program whit this and put into a projector can be very cool, something like a program open source named ...(I can find it, sorry).

Something changing the Audio and realtime images syncronized.

Over 3D objects perhaps can works well... if the code it's very quickly, perhaps changing in realtime the surface don't need too much CPU?¿...  :O

THKS  :good:
Title: Re: Sprite patterns
Post by: Ian Price on 2013-Aug-05
These are pretty simple effects but the results do look very good. 

Very nice, especially this one
(http://www.glbasic.com/forum/index.php?action=dlattach;topic=9381.0;attach=6166;image)
:)
Title: Re: Sprite patterns
Post by: Schranz0r on 2013-Aug-30
Brick,

your avatar an the pictures on right... GODLIKE!  :good:
Title: Re: Sprite patterns
Post by: Brick Redux on 2013-Aug-30
Bless you my.....ARSE , GIRRLS, FECK, DRINK!....DRINK!....DRI....