BASIC

Author Topic: Sprite patterns  (Read 1513 times)

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Sprite patterns
« 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.
A mournful owner of a HP HDX18 Laptop that has died...FECK!

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: Sprite patterns
« Reply #1 on: 2013-Aug-05 »
A tweak.
A mournful owner of a HP HDX18 Laptop that has died...FECK!

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: Sprite patterns
« Reply #2 on: 2013-Aug-05 »
Another.
A mournful owner of a HP HDX18 Laptop that has died...FECK!

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: Sprite patterns
« Reply #3 on: 2013-Aug-05 »
...
A mournful owner of a HP HDX18 Laptop that has died...FECK!

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3318
  • Integrated Brain
    • View Profile
Re: Sprite patterns
« Reply #4 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:

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4090
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Sprite patterns
« Reply #5 on: 2013-Aug-05 »
These are pretty simple effects but the results do look very good. 

Very nice, especially this one

:)
I came. I saw. I played.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4948
  • O Rly?
    • View Profile
Re: Sprite patterns
« Reply #6 on: 2013-Aug-30 »
Brick,

your avatar an the pictures on right... GODLIKE!  :good:
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2600Mhz Ram, HIS 7970 GHz Edition @3GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: Sprite patterns
« Reply #7 on: 2013-Aug-30 »
Bless you my.....ARSE , GIRRLS, FECK, DRINK!....DRINK!....DRI....
A mournful owner of a HP HDX18 Laptop that has died...FECK!