BASIC

Author Topic: APD Particle System in GLBasic - Explosion and Implosion  (Read 3026 times)

Offline aroldo

  • Mr. Polyvector
  • ***
  • Posts: 143
    • View Profile
    • APD Consulting, Inc.
GLBasic Team,

It is the time to contribute and give something back to this developer community. (GLBasic Rocks!) :nw:

First of all I have to say that I am not the best programmer as many in this forum, I have been working with GLB for over 2 years and I keep learning.

A while ago I needed a particle system to simulate an explosion in my game Brick Buster for iOS and WebOS devices.
It should work well on Android but I don't have the devices to test therefore I did not launch it in the Goggle Play market.
(Any volunteers to test it are welcome  :enc:)

There are two attachments, a picture of the test program and the entire GLB Project!!!

The Test Program

When you run the test program you will see the fireworks and a menu with 5 choices.
Just hover the mouse over the option you want and click to increase or change the value of the particle system.
The test program allows you to control the particle system variables as follows:
Particles - this controls the number of particles in the system, from 64 to 1024.
Life - The duration of each particle, from 0.5 to 10.5.
Mode - Explode the particles or Implode the particles.
Dot Size - Is the size of each particle. from 1 to 5
The test program simulates fireworks on the screen and you can turn on and turn off the sound.
Sound -Turns the sound on and off
Bonus
I also included in the test program the following functions:
Mouse control
Text formatting and mouse hover, both will automatically adjust to any screen size.

Using the Particle System
In your program you first call the allocParticle() to instanciate the particle system.
Then you call drawparticles() to draw then in the particle array object.
Last you call moveparticles() from your update function.
 The particle Type object has the following variables:
Code: GLBasic [Select]
TYPE  Tparticle
        x=0  
        y=0
        sine=0
        cosine=0
        speed=0
        life#=0.0
        colors=0                //points to array of colors
ENDTYPE
This particle system has 2 features: Explode and Implode.

Gernot can you pin this post to the Code Snippets? :good:

Play with it and I hope you enjoy :D
« Last Edit: 2013-Jul-26 by aroldo »
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4177
    • View Profile
    • Portfolio
Really nice Aroldo!

I will give a go on the test code on android later on and report back here.
Tks for sharing! :good:

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4177
    • View Profile
    • Portfolio
Gave a try on the testcode on PC.

Tried long 10.5 life, biggest particle size and implode.
On some occasions(~1 out of 10), one particle stays static on screen and won´t move like the rest.

edit: I also notice this dosen´t happen on explode, only on implode.

« Last Edit: 2013-Jul-26 by erico »

Offline aroldo

  • Mr. Polyvector
  • ***
  • Posts: 143
    • View Profile
    • APD Consulting, Inc.
Enrico,

I noticed that too. I will have to debug it to understand which one pixel is not moving.
Other than that it is a nice little particle system.

Regarding he android test thank you for doing that. :nw: I will send you the BrickBuster compile for android.

Can I send it to your e-mail?
What kind of Android devices you have?
BrickBuster should work on screen sizer from 320x480 to 1536x2048.
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4177
    • View Profile
    • Portfolio
Enrrrricoooo Suaaaaveee!! :D :D

It sure is a nice particle system, and the code seems like it is not too complicated to use by your instructions! That is really nice.

I will give a go later today on the test for android.
I would need to finish up some ongoing things before.

You can send anything for test to my ericomont(googlething).

I have a galaxy note II. It runs 1280x720.
Cheers, thanks again for the contribution and instructions!

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2602
    • View Profile
Particle systems are always fun, thanks Aroldo!  :good:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)