Here is a little project I'm fiddling with (sick of banging my head against a wall with my other projects!)
Anyway, at the moment it's a load of balls (har har) and I wanted to make it look like a 'fluid'... any ideas? I've been trying to use textured plains but it doesn't make it look right. I was hoping to make it look like ink in water.
Click on the screen and drag to make the particles follow you
I have an idea for the rest of the game but the graphics eludes me and I know how you all have lots of great ideas!
Shucks, here's the code for "Fluid" as it stands... feel free to use it to illustrate your idea (or steal it and make a cool game)
Rem Project: Fluid
Rem Created: Thursday, July 22, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
position camera 0,0,-100
color backdrop rgb(255,255,255)
set text font "Verdana":set text size 12
ink rgb(20,20,20)
`arrays
type fluids
x as float `start pos x
y as float `start pos y
vx as float `velocity x
vy as float `velocity y
n as integer `nearest buddy
aidir as float `direction in ai mode
aitime as integer `time till next change of direction
aimode as integer `ai mode 1=aimless wandering 2=running away
speed as float `ai speed (fluctuates)
endtype
dim fluid(100) as fluids
type in
rot as float
time as integer
fade as float
curr as integer
endtype
dim inkplane(100) as in
KD SetAnisotropy 16
`make fluid
global num as integer
num=20
for x=1 to num
`make dummies
make object sphere x,4
position object x,rnd(100)-50,rnd(100)-50,0
sc_setupobject x,1,1
next
`make pick plane
make object plane 999,300,300
load image "clear.png",999
texture object 999,999
set object transparency 999,2
`globals
global mc as integer `mouse click
global click as integer `mouse click and no previous
global drag as integer `mouse click and previous
global mh as integer `mouse hold time start
global pmc as integer `previous mouseclick
global mx as float `mouse x
global my as float `mouse y
global mmx as float `mousemove x
global mmy as float `mousemove y
global held as integer `currently held fluid object
global sw as integer `screen width
global sh as integer `screen height
global px as float `pick x
global py as float `pick y
sw=screen width()
sh=screen height()
`####################### MAIN LOOP
do
set cursor 0,0
print "fps:",screen fps()
fluid_data("start") `save start positions and nearest particle
mouse_data() `get mouse clicks and movement
pick_data() `get mouse position in 3D
play() `do interactions
fluid_data("collision") `do sliding collision detection
sync
pmc=mc
loop
`####################### MAIN LOOP
function dist(obj)
x#=object screen x(obj)
y#=object screen y(obj)
d#=sqrt((mx-x#)^2+(my-y#)^2)
endfunction d#
function pick_data()
p=pick object(mx,my,999,999)
if p<>0
x#=get pick vector x()
y#=get pick vector y()
px=x#+camera position x()
py=y#+camera position y()
endif
endfunction
function mouse_data()
mc=mouseclick()
mx=mousex()
my=mousey()
mmx=mousemovex()
mmy=mousemovey()
click=0
if mc=1
if pmc=0
click=1
mh=timer()
endif
drag=1
else
drag=0
endif
endfunction
function nearest()
mind#=10000
for f=1 to num
d#=dist(f)
if d#<mind#
mind#=d#
n=f
endif
next
endfunction n
function nearest_to(obj)
mind#=10000
for f=1 to num
if f<>obj
x#=object position x(f)-object position x(obj)
y#=object position y(f)-object position y(obj)
d#=sqrt(x#^2+y#^2)
if d#<mind#
mind#=d#
n=f
endif
endif
next
endfunction n
function fluid_data(mode$)
if mode$="start"
for f=1 to num
fluid(f).x=object position x(f)
fluid(f).y=object position y(f)
fluid(f).n=nearest_to(f)
next
endif
if mode$="collision"
for f=1 to num
sc_updateobject f
x#=object position x(f)
y#=object position y(f)
hit=sc_sphereslidegroup(1,fluid(f).x,fluid(f).y,0,x#,y#,0,2,f)
if hit<>0
sx#=sc_getcollisionslidex()
sy#=sc_getcollisionslidey()
position object f,sx#,sy#,0
endif
sc_updateobject f
fluid(f).vx=object position x(f)-fluid(f).x
fluid(f).vy=object position y(f)-fluid(f).y
next
endif
endfunction
function play()
`on mouseclick
if click=1
held=nearest()
else
if drag+mc=0 then held=0
endif
`on drag
if drag=1
follow_me()
else
for f=1 to num
position object f,object position x(f)+fluid(f).vx*.9,object position y(f)+fluid(f).vy*.9,0
ai(f)
next
endif
endfunction
function follow_me()
for f=1 to num
d#=dist(f)
mx#=sw*.25
mn#=sw*.05
if d#<mx# and d#>mn#
point object f,px,py,0
move object f,(mx#-d#)*.005
else
position object f,object position x(f)+fluid(f).vx*.9,object position y(f)+fluid(f).vy*.9,0
ai(f)
endif
next
endfunction
function ai(f)
m=fluid(f).aimode
d#=fluid(f).aidir
t=fluid(f).aitime
s#=fluid(f).speed
s#=s#+1
if s#>90 then s#=0
if m=0
m=1
d#=rnd(360)
s#=rnd(90)
t=timer()+2000+rnd(10000)
rotate object f,90,0,0
turn object right f,d#
endif
select m
case 1 `aimless wandering
if timer()>=t
m=1
d#=rnd(360)
t=timer()+2000+rnd(10000)
s#=rnd(90)
rotate object f,90,0,0
turn object right f,d#
else
rotate object f,90,0,0
turn object right f,d#
move object f,sin(s#*.005)
endif
endcase
endselect
fluid(f).aimode=m
fluid(f).aidir=d#
fluid(f).aitime=t
fluid(f).speed=s#
endfunction
This isn't a team request I'm just looking for ideas! Please take this in the manner it's intended, yes I'm after some easy ideas but I think I've done a decent amount of work to start with on this and the game will be free if I ever finish it.