Hi! This does what you need, i hope.
// Project: RandomFire
// Created: 19-05-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle("RandomFire")
SetWindowSize(1024, 768, 0)
SetWindowAllowResize(1) // allow the user to resize the window
// set display properties
SetVirtualResolution(1024, 768) // doesn't have to match the window
SetOrientationAllowed(1, 1, 1, 1) // allow both portrait and landscape on mobile devices
SetSyncRate(30, 0) // 30fps instead of 60 to save battery
SetScissor(0, 0, 0, 0) // use the maximum available screen space, no black borders
UseNewDefaultFonts(1)
img_star1px = LoadImage( "star1px.png" )
type bullet
sprite as integer
x as float
y as float
d as float
speed as float
endtype
global blist as bullet[]
do
if GetRawMouseLeftPressed()
for iter = 1 to 30
local b as bullet
b.sprite = CreateSprite( img_star1px )
SetSpriteScale(b.sprite, 1.5, 1.5)
b.x = GetRawMouseX()
b.y = GetRawMouseY()
b.d = random( 1, 359 ) / 1.0
b.speed = random ( 1, 3 )
blist.insert(b)
next
endif
if blist.length > -1
for iter2 = blist.length to 0 step -1
blist[iter2].x = blist[iter2].x + cos( blist[iter2].d ) * blist[iter2].speed
blist[iter2].y = blist[iter2].y + sin( blist[iter2].d ) * blist[iter2].speed
SetSpritePosition(blist[iter2].sprite, blist[iter2].x, blist[iter2].y)
next
endif
Print(ScreenFPS())
Sync()
loop
This version deletes the particles that go offscreen.
// Project: RandomFire
// Created: 19-05-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle("RandomFire")
SetWindowSize(1024, 768, 0)
SetWindowAllowResize(1) // allow the user to resize the window
// set display properties
SetVirtualResolution(1024, 768) // doesn't have to match the window
SetOrientationAllowed(1, 1, 1, 1) // allow both portrait and landscape on mobile devices
SetSyncRate(30, 0) // 30fps instead of 60 to save battery
SetScissor(0, 0, 0, 0) // use the maximum available screen space, no black borders
UseNewDefaultFonts(1)
img_star1px = LoadImage( "star1px.png" )
type bullet
sprite as integer
x as float
y as float
d as float
speed as float
endtype
global blist as bullet[]
do
if GetRawMouseLeftPressed()
for iter = 1 to 30
local b as bullet
b.sprite = CreateSprite( img_star1px )
SetSpriteScale(b.sprite, 1.5, 1.5)
b.x = GetRawMouseX()
b.y = GetRawMouseY()
b.d = random( 1, 359 ) / 1.0
b.speed = random ( 1, 3 )
blist.insert(b)
next
endif
if blist.length > -1
for iter2 = blist.length to 0 step -1
if blist[iter2].x > 1024 or blist[iter2].x < 0 or blist[iter2].y > 768 or blist[iter2].y < 0
DeleteSprite(blist[iter2].sprite)
blist.remove(iter2)
continue
endif
blist[iter2].x = blist[iter2].x + cos( blist[iter2].d ) * blist[iter2].speed
blist[iter2].y = blist[iter2].y + sin( blist[iter2].d ) * blist[iter2].speed
SetSpritePosition(blist[iter2].sprite, blist[iter2].x, blist[iter2].y)
next
endif
Print(ScreenFPS())
Sync()
loop
Win 10 Pro - AMD RYZEN 7 Octacore 3.8ghz - 32GB DDR4 - RTX 2070 8GB