i knocked this up with 1.63w2
3d starfield with gravity effect and hyperspace
New version with a wipe
version 1.1 full screen seems to run at full speed
Looks pretty good, although seems a tad familiar :)
originality was never my strong point
did you press g?
yeah, I did play the controls a bit
Hmm for some reason when deployed the starfield seems to run very slowly(6 fps) until i press T or G.......
yet it doesn't do it when compiled from the IDE
only 1 more post to my 100th woohoo
that one's a lot slower than other version
hmm - if you press G or T it reverts to full speed
[/quote]
Quote from: monkeybot on February 03, 2009, 09:47:03 AM
Hmm for some reason when deployed the starfield seems to run very slowly(6 fps) until i press T or G.......
yet it doesn't do it when compiled from the IDE
Rather than double posting (you 101 poster you), wouldn't it be more useful to post the code.
i would be all embarrassed
hi Monkeybot
nice demo , like gravity effect works well very effective m would like to see the code for this if posssible
mick :)
Quote from: monkeybot on February 03, 2009, 03:11:00 PM
i would be all embarrassed
There's nothing to worried about. The more people contributing snippets (big or small), the more knowledge and ideas can be shared.
ok i will tidy it up a bit and post soon(ish)
look forward to code
mick :)
This is very rough,but hey i am busy.......
[pbcode]
; PROJECT : blob emiiter v 1.0
; AUTHOR : Monkeybot
; CREATED : 02/02/2009
; EDITED : 11/03/2009
; ---------------------------------------------------------------------
; ---------------------------------------------------------------------
;to do
explicit on
;screenvsync off
local num=1000
global width=getscreenwidth()
global height=getscreenheight()
constant border=0
constant xborder=50
Constant gravityVal#=0.5
global originX=width/2
global originY=height/2
global trailtimer=timer()
global gamespeed#=1
global offsetXVector#
global offsetYVector#
global offsetAngle=0
global hx,hy,h2x,h2y
type particle
x#
y#
ang
speed#
xVector#
yVector#
PathDistance#
gravityFlag
size#
TrailFlag
trailStartX#
trailStartY#
endtype
dim object(num) as particle
print "Working..............."
sync
local q,buttonflag,w
offsetXVector#=0
offsetYVector#=0
for q=0 to num-1
pokedata (q)
next
;initiate random stars
for w=0 to 100;000
;print w
; sync
for q=0 to num-1
doblobNoGfx(q)
next
next
setfps(50)
repeat
cls 0
if (203=scancode()) then offsetAngle=offsetAngle-5;offsetXVector#
if (205=scancode()) then offsetAngle=offsetAngle+5
offsetXVector#=cos(offsetAngle)*5;object(index).speed#
offsetYVector#=sin(offsetAngle)*5;object(index).speed#
select mousebutton()
case 0
if gamespeed#>0.5 then gamespeed#=gamespeed#-0.01
case 1
if gamespeed#<6 then gamespeed#=gamespeed#+0.2
case 2
if gamespeed#>0.5 then gamespeed#=gamespeed#-0.2
endselect
lockbuffer
;cls 0
for q=0 to num-1
doblob(q)
next
ink $00;ff00
box 0,0,width,xborder,1
box 0,height-(xborder-1),width,height,1
box 0,0,xborder,height,1
box width-(xborder+1),0,width,height,1
ink $ffffff
box xborder,xborder,width-xborder,height-xborder,0
print "Num of particles "+str$(num)+" fps "+str$(fps())+" Speed "+str$(gamespeed#)
print "left/right mouse speed up/down "+str$(offsetAngle)
print "Key G - For grav effect // Key T for Warp // Q-Quit"
if timer()<trailtimer+500 then print "timer active"
local x1,y1,x2,y2,length=100
x1=cos(offsetAngle)*(length/2)
y1=sin(offsetAngle)*(length/2)
x2=cos(offsetAngle)*(length/2)
y2=sin(offsetAngle)*(length/2)
ink $ff
line (width/2)-x1,(height/2)-y1,(width/2)+x2,(height/2)+y2
circle (width/2),(height/2),4,2
circle(width/2)-x1,(height/2)-y1,4,2
circle(width/2)+x2,(height/2)+y2,4,2
unlockbuffer
sync
until (1=scancode()) or (16=scancode()) ;esc/q
waitnokey
; repeat
setfps(250);c
lockbuffer
for q=0 to height/2 step 1
ink $fffffff
box 0+q+1,0+q+1,width-q-1,height-q-1,0
ink 0
box 0+q,0+q,width-q,height-q,0
sync
ink $fffffff
box 0+q+1,0+q+1,width-q-1,height-q-1,0
ink 0
box 0+q,0+q,width-q,height-q,0
sync
next
unlockbuffer
ink $ffffff
local size
setfps(30)
cls 0
sync
cls 0
for size=0 to 20
line (width/2)-size,(height/2),(width/2)+size,(height/2)
line (width/2),(height/2)-size,(width/2),(height/2)+size
sync
next
for size=20 to 0 step-1
cls 0
line (width/2)-size,(height/2),(width/2)+size,(height/2)
line (width/2),(height/2)-size,(width/2),(height/2)+size
sync
next
cls 0
end
Function doblob(index)
;trail on ,no T key pressed and timer>500ms
local colour,col
if object(index).trailflag=true and (0=keystate(20)) and timer()>trailtimer+500
object(index).trailStartx# = object(index).trailStartx# + (object(index).xVector#*gamespeed#)*2 ;catch up
object(index).trailStarty# = object(index).trailStarty# + (object(index).yVector#*gamespeed#)*2
local distance#
distance#=getdistance2d(object(index).trailStartx#,object(index).trailStarty#,object(index).x#,object(index).y#)
if distance#<10
object(index).trailFlag=false
gameSpeed#=2;oldGameSpeed#
endif
endif
;*********** ;T key pressed initiate trial
if (1=keystate(20)) ;and gamespeed#>4 ;T - pressed
if object(index).TrailFlag=false and object(index).gravityFlag=false ;and gamespeed#>4
object(index).trailStartX=object(index).x
object(index).trailStartY=object(index).y
;oldGameSpeed#=gameSpeed#
gamespeed#=0.5
object(index).trailFlag=true
trailtimer=timer()
endif
endif
;;******* Gravity effect
if (34=scancode()) ;G
object(index).gravityFlag=true
object(index).TrailFlag=false
trailtimer=0
endif
if object(index).gravityFlag=true
object(index).yVector# = object(index).yVector# + gravityVal#
object(index).x# = object(index).x# + object(index).xVector#
object(index).y# = object(index).y# + object(index).yVector#
if object(index).y#>height-(xborder)
object(index).yVector# =-((object(index).yVector#)*0.75)
if abs(object(index).yVector#)<2 then pokedata(index)
endif
endif
if (object(index).x#>width-border or (object(index).x#<border) ) then pokeData(index)
;************* Flying bit
if object(index).gravityFlag=false
object(index).x# = object(index).x# + object(index).xVector#*gamespeed#
object(index).y# = object(index).y# + object(index).yVector#*gamespeed#
object(index).size=object(index).size+0.01*gamespeed#
if (object(index).y#>height-border or (object(index).y#<border) ) then pokeData(index) ;respawn particle
endif
object(index).PathDistance# = getdistance2d (400,300,object(index).x#,object(index).y#);
;;;;Display bit
col=$22+object(index).PathDistance#
if col>$ff then col=$ff
if object(index).size>3 then object(index).size=3
colour=rgb(col,col,col)
if object(index).gravityFlag=true then colour=$ff0000
if object(index).trailflag=false then circlec object(index).x,object(index).y,object(index).size,1,colour
if object(index).trailflag=true
linec object(index).x#,object(index).y#,object(index).trailStartX#,object(index).trailStartY#,$FFFFFF
endif
EndFunction
Function doblobNoGfx(index)
if (object(index).x#>width-border or (object(index).x#<border) ) then pokeData(index)
if (object(index).y#>height-border or (object(index).y#<border) ) then pokeData(index)
object(index).x# = object(index).x# + object(index).xVector#*10
object(index).y# = object(index).y# + object(index).yVector#*10
object(index).size=object(index).size+0.01*10
object(index).PathDistance# = getdistance2d (400,300,object(index).x#,object(index).y#);
EndFunction
Function pokeData(index)
local ang
object(index).speed#=1+(rnd(3))
object(index).x=(originX);-20)+rnd(40)
object(index).y=(originY);-20)+rnd(40)
ang=rnd (360)
object(index).xVector#=cos(ang)*object(index).speed#
object(index).yVector#=sin(ang)*object(index).speed#
object(index).PathDistance#=0
object(index).gravityFlag=false
object(index).size=1
object(index).trailflag=false
EndFunction
[/pbcode]
Here's a bit of a tweak.
[pbcode]
; PROJECT : blob emiiter v 1.0
; AUTHOR : Monkeybot
; CREATED : 02/02/2009
; EDITED : 11/03/2009
; ---------------------------------------------------------------------
; ---------------------------------------------------------------------
;to do
explicit on
;screenvsync off
local num=1000
global width=getscreenwidth()
global height=getscreenheight()
constant border=0
constant xborder=50
Constant gravityVal#=0.5
global originX=width/2
global originY=height/2
global trailtimer=timer()
global gamespeed#=1
global offsetXVector#
global offsetYVector#
global offsetAngle=0
global hx,hy,h2x,h2y
type particle
x#
y#
ang
speed#
xVector#
yVector#
PathDistance#
gravityFlag
size#
TrailFlag
trailStartX#
trailStartY#
endtype
dim object(num) as particle
print "Working..............."
sync
local q,buttonflag,w
offsetXVector#=0
offsetYVector#=0
for q=0 to num-1
pokedata (q)
next
;initiate random stars
for w=0 to 100;000
;print w
; sync
for q=0 to num-1
doblobNoGfx(q)
next
next
; setfps(50)
setfps 0
repeat
cls 0
if (203=scancode()) then offsetAngle=offsetAngle-5;offsetXVector#
if (205=scancode()) then offsetAngle=offsetAngle+5
offsetXVector#=cos(offsetAngle)*5;object(index).speed#
offsetYVector#=sin(offsetAngle)*5;object(index).speed#
select mousebutton()
case 0
if gamespeed#>0.5 then gamespeed#=gamespeed#-0.01
case 1
if gamespeed#<6 then gamespeed#=gamespeed#+0.2
case 2
if gamespeed#>0.5 then gamespeed#=gamespeed#-0.2
endselect
ScreenViewport xborder,xborder,width-xborder,height-xborder
lockbuffer
global SpaceKeyDown =(34=scancode())
Global tKeyDown = (keystate(20))
;cls 0
for q=0 to num-1
doblob(q)
next
ScreenViewport 0,0,getscreenWidth(),GetScreenHeight()
ink $ffffff
box xborder,xborder,width-xborder,height-xborder,0
print "Num of particles "+str$(num)+" fps "+str$(fps())+" Speed "+str$(gamespeed#)
print "left/right mouse speed up/down "+str$(offsetAngle)
print "Key G - For grav effect // Key T for Warp // Q-Quit"
if timer()<trailtimer+500 then print "timer active"
local x1,y1,x2,y2,length=100
x1=cos(offsetAngle)*(length/2)
y1=sin(offsetAngle)*(length/2)
x2=cos(offsetAngle)*(length/2)
y2=sin(offsetAngle)*(length/2)
ink $ff
line (width/2)-x1,(height/2)-y1,(width/2)+x2,(height/2)+y2
circle (width/2),(height/2),4,2
circle(width/2)-x1,(height/2)-y1,4,2
circle(width/2)+x2,(height/2)+y2,4,2
unlockbuffer
sync
until (1=scancode()) or (16=scancode()) ;esc/q
waitnokey
; repeat
setfps(250);c
for q=0 to height/2 step 1
ink $fffffff
box 0+q+1,0+q+1,width-q-1,height-q-1,0
ink 0
box 0+q,0+q,width-q,height-q,0
sync
ink $fffffff
box 0+q+1,0+q+1,width-q-1,height-q-1,0
ink 0
box 0+q,0+q,width-q,height-q,0
sync
next
ink $ffffff
local size
setfps(30)
cls 0
sync
cls 0
for size=0 to 20
line (width/2)-size,(height/2),(width/2)+size,(height/2)
line (width/2),(height/2)-size,(width/2),(height/2)+size
sync
next
for size=20 to 0 step-1
cls 0
line (width/2)-size,(height/2),(width/2)+size,(height/2)
line (width/2),(height/2)-size,(width/2),(height/2)+size
sync
next
cls 0
end
Psub doblob(index)
;trail on ,no T key pressed and timer>500ms
local colour,col
if object(index).trailflag=true
if (0=tKeyDown)
if timer()>trailtimer+500
object(index).trailStartx# = object(index).trailStartx# + (object(index).xVector#*gamespeed#)*2 ;catch up
object(index).trailStarty# = object(index).trailStarty# + (object(index).yVector#*gamespeed#)*2
local distance#=getdistance2d(object(index).trailStartx#,object(index).trailStarty#,object(index).x#,object(index).y#)
if distance#<10
object(index).trailFlag=false
gameSpeed#=2;oldGameSpeed#
endif
endif
endif
else
;*********** ;T key pressed initiate trial
if TkeyDown
if object(index).gravityFlag=false ;and gamespeed#>4
object(index).trailStartX=object(index).x
object(index).trailStartY=object(index).y
;oldGameSpeed#=gameSpeed#
gamespeed#=0.5
object(index).trailFlag=true
trailtimer=timer()
endif
endif
endif
;;******* Gravity effect
if SpaceKeyDown ;G
object(index).gravityFlag=true
object(index).TrailFlag=false
trailtimer=0
endif
if object(index).gravityFlag=true
object(index).yVector# = object(index).yVector# + gravityVal#
object(index).x# = object(index).x# + object(index).xVector#
object(index).y# = object(index).y# + object(index).yVector#
if object(index).y#>height-(xborder)
object(index).yVector# =-((object(index).yVector#)*0.75)
if abs(object(index).yVector#)<2 then pokedata(index)
endif
endif
if (object(index).x#>width-border or (object(index).x#<border) ) then pokeData(index)
;************* Flying bit
if object(index).gravityFlag=false
object(index).x# = object(index).x# + object(index).xVector#*gamespeed#
object(index).y# = object(index).y# + object(index).yVector#*gamespeed#
object(index).size=object(index).size+0.01*gamespeed#
if (object(index).y#>height-border or (object(index).y#<border) ) then pokeData(index) ;respawn particle
endif
object(index).PathDistance# = getdistance2d(400,300,object(index).x#,object(index).y#);
;;;;Display bit
col=$22+object(index).PathDistance#
if col>$ff then col=$ff
if object(index).size>3 then object(index).size=3
colour=rgb(col,col,col)
if object(index).gravityFlag=true then colour=$ff0000
if object(index).trailflag=true
linec object(index).x#,object(index).y#,object(index).trailStartX#,object(index).trailStartY#,$FFFFFF
else
circlec object(index).x,object(index).y,object(index).size,1,colour
endif
EndPsub
Psub doblobNoGfx(index)
if (object(index).x#>width-border or (object(index).x#<border) ) then pokeData(index)
if (object(index).y#>height-border or (object(index).y#<border) ) then pokeData(index)
object(index).x# = object(index).x# + object(index).xVector#*10
object(index).y# = object(index).y# + object(index).yVector#*10
object(index).size=object(index).size+0.01*10
object(index).PathDistance# = getdistance2d (400,300,object(index).x#,object(index).y#);
EndPsub
Psub pokeData(index)
local ang
local Speed#=1+(rnd(3))
object(index).speed#=Speed#
object(index).x=(originX);-20)+rnd(40)
object(index).y=(originY);-20)+rnd(40)
ang=rnd (360)
object(index).xVector#=cosRadius(ang,Speed#)
object(index).yVector#=sinRadius(ang,Speed#)
object(index).PathDistance#=0
object(index).gravityFlag=false
object(index).size=1
object(index).trailflag=false
EndPsub
[/pbcode]
I like it when you quit the game. The screen closes in on itself and displays a little star, much like an old television.
Hi monkeybot ,
Thanks for posting code , i will poke my nose in this as soon as possible , maths look very complicated , wish i was this good at maths , well done
looks very effective
mick :)
ahhhh ScreenViewport thats what i was looking for
Oddly enough, the main bottleneck was the KeyState() functions really. Which as it turns out to be slower than one would expect.
100 fps difference just with that command change!
It would be nice to have a code profiler.... :)