Posted: 14th Jun 2007 17:52
Hi community,

I've created some different function-collections about the last months (timers, text, strings, mouse-functions..) and it's always funny and motivating.

My problem is, that I ran out of ideas what I can do next. I sometimes also work on an image function-collection for easier editing, filters etc. but want to do something else...

So, does anyone have ideas, what I could do?
If you know any possible functions I could write, I might do it.. of course they are for everyone's use then.

I'd really apreciate it, if some people post their ideas here, so that I can go on programming.

If you don't know what I am talking about I could try to explain what I want better.

Thanks,
Mr Kohlenstoff
Posted: 14th Jun 2007 19:20
Real Waterfalls, Real weather system, and real oceans with real waves + seafoam (NON-MATRIX STYLE) would be a GREAT start! =)

~M.W~
Posted: 14th Jun 2007 19:34
Uuh.. that would be much work, and I don't think I could do that all, but I could try doing a small weather system.. shouldn't be TO hard. We'll see.. nevertheless, any other ideas?
Posted: 14th Jun 2007 19:41
Weather system = awesome!

Maybe some CLEAR rain, thunder, and lightning (Blue streaks of lightning) =)

~M.W~
Posted: 14th Jun 2007 19:45
I don't know if I would include all the effects in the system, or just write functions for easier handling.. so that everyone can make the effects on his own, but doesn't have to get along with all the variables etc.
We'll see, I'm going to start it now.. and look if I can create a code of good quality.
Posted: 14th Jun 2007 20:37
Functions == better anyway!

~M.W~
Posted: 14th Jun 2007 21:01
200 Lines of code now.. I think I'll seperate 2D and 3D, so you can choose, if you want to have your rain, fog etc. shown with sprites or with plains/dbp fog... I think tomorrow I'll have a pre-pre-pre-alpha-version of it.

Edit: OK, I had no time for programming today.. but I think a big part of the weather-system is ready, and tomorrow I will try to create a small example-program to demonstrate the actual state.
Posted: 16th Jun 2007 14:11
I've created a first part of 2D-Weather.. but there's a problem: all the time I create a new Raindrop the dynamic drop-array is resized, as consequence the application slows down.. the problem would be even bigger in 3D, when all the time a new plain is created.
However... here's the code so far (~430 lines):

+ Code Snippet
rem Mr Kohlenstoff's weather-system

remstart
   functions:

   *General*
   -start_mws intImageStart, intSpriteStart, intPlainStart [the first sprite/plain the functions may use]
   -update_mws
   -mws_SetMode btMode [0=nothing, 1=2D, 2=3D]

   *Rain/Snow*
   -mws_SetRain intRainType [0=no rain, 1=rain, 2=snow, x=user-defined rain]
   -mws_CreateRain(intImageID, intFallSpeed#, intSound, btAlpha) = int
   -mws_SetRainIntensity intIntensity [defines, how much sprites or objects are show]

   *Fog*
   -mws_SetFog intFogType [0=no, 1=normal(grey), 2=night(black/blue), x=user-defined fog]
   -mws_CreateFog(btRed,btGreen,btBlue,btAlpha,boolDBPFog) = int [if boolDBPFog=1, the program will use dark basic fog, else it will use a sprite]
   -mws_SetFotIntensity intAlpha [percent-value: 100 -> fog-alpha, 0 -> 0, 200 -> fog-alpha*2(max 255)]

   *Wind*
   -mws_SetWind fltXSpeed, fltYSpeed, fltZSpeed
   -mws_AutoHandleWind fltMaxX, fltMaxY, fltMaxZ
   -mws_StopAutoWind [Stops wind auto-handling]
   -mws_SetWindSound intSound
   -mws_GetWindSpeed() = flt
   -mws_GetWindXSpeed() = flt
   -mws_GetWindYSpeed() = flt
   -mws_GetWindZSpeed() = flt
   -(mws_GetWindDir() = flt [returns angle])

   *Not for user*
   -mws_Random(fltValue) = flt [returns a random float between 0 and fltValue]
   -mws_AddRain() = int [creates a new element in the rain-array]

remend

rem *****EXAMPLE***** ===========================================

      set display mode 800,600,32
      sync on : sync rate 200
      Start_mws 1,1,1
      mws_AutoHandleWind(1,1,1)
      rem Get rain image
      ink rgb(50,70,230),0 : box 1,1,3,12 : get image 1, 1,1,3,12, 1
      rain = mws_CreateRain(1,3.0,0,128)
      rem Get snow image
      mws_SetRain(rain)
      mws_SetRainIntensity(1000)
      mws_RainGroundLevel = 600
      rem Fog
      fog = mws_CreateFog(200,200,200,150,0)
      mws_SetFog(fog)
      rem Activate all
      mws_SetMode(MWS_MODE_2D)
      rem mainloop
      do
         box 0,0,800,400, rgb(50,50,255), rgb(150,150,255), rgb(60,60,255), rgb(140,140,255)
         box 0,400,800,600, rgb(100,40,10), rgb(90,40,30), rgb(90,35,8), rgb(90,38,28)
         set cursor 0,0
         print "FPS: ", screen fps()
         print "Drops: ", mws_DropCount
         rem Show wind
         line 30,50,30+mws_WindX*10,50+mws_WindY*10
         update_mws
         sync
      loop

rem *****EXAMPLE-END***** =======================================

rem Constants
#constant MWS_MODE_OFF = 0
#constant MWS_MODE_2D  = 1
#constant MWS_MODE_3D  = 2

rem **This function should be called before all other MWS-Function!**
#constant start_mws = Start_MWS()
function Start_MWS(ImgS,SprS,PlnS)
   rem General Variables
   global mws_ActMode  as integer
   global mws_LastMode as integer
   global mws_FirstImage  as integer : mws_FistImage  = ImgS-1
   global mws_FirstSprite as integer : mws_FistSprite = SprS-1
   global mws_FirstPlain  as integer : mws_FistPlain  = PlnS-1
   rem Rain
   global mws_RainCount as integer : mws_RainCount = 0
   dim mws_Rain(0) as mws_RainType
   dim mws_RainDrop(0) as mws_DropType
   global mws_RainIntensity as integer
   global mws_ActRain as integer `Selected Rain
   global mws_RainFirstPlain as integer `First plain used
   global mws_RainLastPlain  as integer `Last plain used
   global mws_RainSprite as integer `used sprite
   global mws_RainGroundLevel as float `The height where all drops are destroyed/replaced (for 2D and 3D)
   global mws_DropCount as integer `Number of raindrops
   rem Fog
   global mws_FogCount as integer : mws_FogCount = 0
   dim mws_Fog(0) as mws_FogType
   global mws_FogIntensity as integer `percent-value
   global mws_ActFog as integer `Selected Fog
   global mws_FogSprite as integer
   rem Wind
   global mws_WindX as float
   global mws_WindY as float
   global mws_WindZ as float
   global mws_WindSpeed as float
   `global mws_WindDir as float
   global mws_WindSound as integer `Sound-ID (0 -> no sound, else sound X is looped)
   global mws_AutoWind as boolean `Automatic wind-handling (direction-change)
   global mws_WindMaxX as float `for Auto-Wind
   global mws_WindMaxY as float `for Auto-Wind
   global mws_WindMaxZ as float `for Auto-Wind
endfunction

type mws_RainType
   Img as integer `Image-ID
   `Spr as integer `Sprite-ID [image-id reicht, sprite wird dann neu erstellt]
   Alpha as byte `Alpha-value
   FallSpeedMin as float `minimum fall-speed of drops
   FallSpeedMax as float `maximum fall-speed of drops
   Sound as integer `Sound-ID
endtype

type mws_DropType
   X as float
   Y as float
   Z as float `in 2D maybe shown with smaller sprites?
   Speed as float
endtype

type mws_FogType
   Col as dword
   R as byte
   G as byte
   B as byte
   A as byte
   Img as integer `Image-ID
   Spr as integer `Sprite-ID, if 0 then DBP-fog is used
endtype



rem **This function updates all modern-weather-system-operations, which run automatically (e.g. automatic wind)**
#constant update_mws = Update_MWS()
function Update_MWS()

   rem Automatic Wind
   if mws_AutoWind = 1

      rem Change directions
      inc mws_WindX, mws_Random(mws_WindMaxX)*0.1-mws_WindMaxX*0.05
      inc mws_WindY, mws_Random(mws_WindMaxY)*0.1-mws_WindMaxY*0.05

      rem Avoid to high/low values
      if mws_WindX >  mws_WindMaxX then mws_WindX =  mws_WindMaxX
      if mws_WindX < -mws_WindMaxX then mws_WindX = -mws_WindMaxX
      if mws_WindY >  mws_WindMaxY then mws_WindY =  mws_WindMaxY
      if mws_WindY < -mws_WindMaxY then mws_WindY = -mws_WindMaxY

      rem Z-Operations if 3D
      if mws_ActMode = MWS_MODE_3D
         inc mws_WindZ, mws_Random(mws_WindMaxZ)-mws_WindMaxZ/2.0
         if mws_WindZ >  mws_WindMaxZ then mws_WindZ =  mws_WindMaxZ
         if mws_WindZ < -mws_WindMaxZ then mws_WindZ = -mws_WindMaxZ
         mws_WindSpeed = sqrt(mws_WindX^2+mws_WindY^2+mws_WindZ^2) `Wind-Speed
      else
         mws_WindSpeed = sqrt(mws_WindX^2+mws_WindY^2) `Wind-Speed
      endif

      rem Update variables
      `mws_WindDir   = atanfull(mws_WindX,mws_WindY)
   endif

   rem *Update Positions etc*
   rem Gravity- and Wind-Operations
   for d = 1 to mws_DropCount
      inc mws_RainDrop(d).Y, mws_RainDrop(d).Speed
      inc mws_RainDrop(d).X, mws_WindX
      inc mws_RainDrop(d).Z, mws_WindZ
      if mws_RainDrop(d).Y > mws_RainGroundLevel `Drop reaches ground
         if mws_DropCount <= mws_RainIntensity `Right amount of drops active
            mws_ResetDrop(d)
         else `Too much drops active
            mws_DeleteDrop(d)
         endif
      endif
   next d

   rem Check Graphics-Mode and update variables, graphics etc
   select mws_ActMode
      rem No wather
      case MWS_MODE_OFF
      endcase
      rem 2D-Effects
      case MWS_MODE_2D
         rem Add drops
         if mws_DropCount < mws_RainIntensity
            if rnd(5)=1 `<- change!!!
               id = mws_AddDrop()
               mws_ResetDrop(id)
            endif
         endif
         rem Paste drops
         for d = 1 to mws_DropCount
            paste sprite mws_RainSprite, mws_RainDrop(d).x, mws_RainDrop(d).y
         next d
         rem Show fog
         paste sprite mws_FogSprite, 0,0
      endcase
      rem 3D-Effects
      case MWS_MODE_3D
         rem Add drops
         if mws_DropCount < mws_RainIntensity
            if rnd(5)=1 `<- change!!!
               id = mws_AddDrop()
               mws_ResetDrop(id)
            endif
         endif
      endcase
   endselect

endfunction



rem **This function deletes all the media, used by MWS and creates new needed media.
rem You should call this function AFTER creating all your rain-, fog-types etc.**
function mws_SetMode(Mode as byte)
   rem Set Actual Mode
   mws_ActMode = Mode
   rem Reset Wind
   mws_SetWind(0,0,0)
   rem Changes, depending on last mode (**DELETE** images, sprites, objects..)
   select LastMode
      rem *No Weather*
      case MWS_MODE_OFF
      endcase
      rem *2D-Effects*
      case MWS_MODE_2D
         rem Delete rain-sprite
         delete sprite mws_RainSprite
         mws_RainSprite = 0
         rem Fog
         if mws_Fog(mws_ActFog).Spr = 0 `DBP-Fog
            fog off
         else `Sprite
            delete sprite mws_Fog(mws_ActFog).Spr
            mws_Fog(mws_ActFog).Spr = 0
         endif
      endcase
      rem *3D-Effects*
      case MWS_MODE_3D
      endcase
   endselect
   rem Changes, depending on Act Mode  (**CREATE** images, sprites, objects...)
   select Mode
      rem *No Weather*
      case MWS_MODE_OFF
      endcase
      rem *2D-Effects*
      case MWS_MODE_2D
         rem Rain-Sprite
         mws_RainSprite = mws_FreeSprite()
         sprite mws_RainSprite, 0,0, mws_Rain(mws_ActRain).Img
         set sprite alpha mws_RainSprite, mws_Rain(mws_ActRain).Alpha
         hide sprite mws_RainSprite
         rem Fog
         if mws_Fog(mws_ActFog).Spr = 0 `DBP-Fog
            rem Activate DBP-Fog
            fog on
            fog color mws_Fog(mws_ActFog).Col
         else `Sprite
            rem Create screen-filling Fog-Sprite
            mws_FogSprite = mws_FreeSprite()
            sprite mws_FogSprite, 0,0, mws_Fog(mws_ActFog).Img
            size sprite mws_FogSprite, screen width(), screen height()
            set sprite alpha mws_FogSprite, mws_Fog(mws_ActFog).A
            hide sprite mws_FogSprite
         endif
      endcase
      rem *3D-Effects*
      case MWS_MODE_3D
      endcase
   endselect
   rem Set Last mode
   mws_LastMode = Mode
endfunction

rem **This function allows you to create own rain-effects**
function mws_CreateRain(ImageID, FallSpeed#, Sound, Alpha)
   id = mws_AddRain()
   mws_Rain(id).Img = ImageID
   `mws_Rain(id).Spr = 0
   mws_Rain(id).Alpha = Alpha
   mws_Rain(id).FallSpeedMin = FallSpeed#*0.8
   mws_Rain(id).FallSpeedMax = FallSpeed#*1.2
   mws_Rain(id).Sound = Sound
endfunction id

rem **With this function you can select a rain-type**
function mws_SetRain(RainType)
   mws_ActRain = RainType
endfunction

function mws_SetRainGround(Height#)
   mws_RainGroundLevel = Height#
endfunction

rem **Changes the rain-intensity (number of used images/plains)**
function mws_SetRainIntensity(Intensity)
   mws_RainIntensity = Intensity
endfunction

rem **This function allows you to create own fog-effects**
function mws_CreateFog(R as byte,G as byte,B as byte,A as byte, DBPFog as boolean)
   id = mws_AddFog()
   mws_Fog(id).Col = rgb(R,G,B)
   mws_Fog(id).R = R
   mws_Fog(id).G = G
   mws_Fog(id).B = B
   mws_Fog(id).A = A
   rem Create Image
   mem = mws_FreeTempMemblock()
   img = mws_FreeImage()
   make memblock mem, 16
   write memblock dword mem, 0,  1
   write memblock dword mem, 4,  1
   write memblock dword mem, 8, 32
   write memblock byte mem, 12, r
   write memblock byte mem, 13, g
   write memblock byte mem, 14, b
   write memblock byte mem, 15, a
   make image from memblock img, mem
   delete memblock mem
   mws_Fog(id).Img = Img
   if DBPFog = 1 then  mws_Fog(id).Spr = 0 else mws_Fog(id).Spr = -1
endfunction id

rem **With this function you can select a fog-type**
function mws_SetFog(FogType)
   mws_ActFog = FogType
endfunction

rem **Sets the wind-speed**
function mws_SetWind(XSpeed#, YSpeed#, ZSpeed#)
   mws_WindX = XSpeed#
   mws_WindY = YSpeed#
   mws_WindZ = ZSpeed#
endfunction

rem **Wind is handeled by the update-function**
function mws_AutoHandleWind(MaxX#, MaxY#, MaxZ#)
   mws_AutoWind = 1
   mws_WindMaxX = MaxX#
   mws_WindMaxY = MaxY#
   mws_WindMaxZ = MaxZ#
endfunction

rem **Wind is handeled by you**
function mws_StopAutoWind()
   mws_AutoWind = 0
endfunction

rem **SoundID=0 -> no sound, SoundID=1 -> sound looped, volume depending on intensity
function mws_SetWindSound(SoundID)
   mws_WindSound = SoundID
endfunction




function mws_AddRain()
   inc mws_RainCount
   array insert at bottom mws_Rain(0), mws_RainCount
endfunction mws_RainCount

function mws_ResetDrop(id)
   select mws_ActMode
      case MWS_MODE_OFF
      endcase
      case MWS_MODE_2D
         mws_RainDrop(id).X = rnd(screen width())
         mws_RainDrop(id).Y = -rnd(screen height()/2)
         mws_RainDrop(id).Z = rnd(2)
         mws_RainDrop(id).Speed = mws_Rain(mws_ActRain).FallSpeedMin + mws_Random(mws_Rain(mws_ActRain).FallSpeedMax-mws_Rain(mws_ActRain).FallSpeedMin)
      endcase
      case MWS_MODE_3D
         mws_RainDrop(id).X = camera position x()+100-rnd(200)
         mws_RainDrop(id).Y = camera position y()-300-rnd(150)
         mws_RainDrop(id).Z = camera position z()+100-rnd(200)
         mws_RainDrop(id).Speed = mws_Rain(mws_ActRain).FallSpeedMin + mws_Random(mws_Rain(mws_ActRain).FallSpeedMax-mws_Rain(mws_ActRain).FallSpeedMin)
      endcase
   endselect
endfunction

function mws_AddDrop()
   inc mws_DropCount
   array insert at bottom mws_RainDrop(0), mws_DropCount
endfunction mws_DropCount

function mws_DeleteDrop(id)
   dec mws_DropCount
   array delete element mws_RainDrop(0), id
endfunction

function mws_AddFog()
   inc mws_FogCount
   array insert at bottom mws_Fog(0), mws_FogCount
endfunction mws_FogCount

function mws_FreeSprite()
   id = mws_FirstSprite
   repeat
      inc id
   until sprite exist(id)=0
endfunction id

function mws_FreeImage()
   id = mws_FirstImage
   repeat
      inc id
   until image exist(id)=0
endfunction id

function mws_FreeTempMemblock()
   id = 0
   repeat
      inc id
   until memblock exist(id)=0
endfunction id

function mws_Random(v#)
   r# = rnd(v#*100000)/100000.0
endfunction r#
Posted: 16th Jun 2007 14:40
array insert at bottom mws_Rain(0), mws_RainCount
You don't need the index in any of that, I'm not sure if it affects the speed, but this does the same thing:
array insert at bottom mws_Rain()

Then, you just use the current index like this:
mws_Rain().img = ImageID rem for example

Using rnd() is pretty expensive to do on the fly, as well.

I use them dimensionlessly, more or less. They are slower than a fixed size array, but...you might want to just make a large-ish array, and use your index in that. (The array would stay the same size, but only the index down would contain rain drops.

Anyway, that's pretty impressive!
Posted: 16th Jun 2007 14:47
Yes I could do that.. but then the user had to know the maximum amount of raindrops before compiling it.. but I think this would also be OK. But how should I solve the problem in 3D with plains? Is there any command like "paste object"? I'm not sure, but I don't think so.. than I had to create thousands of plains at the beginning and exclude them first, and activate them later... or do you have any better idea?
Thanks for your interest.
Posted: 16th Jun 2007 14:49
I think it would be better to just have light rain to torrential downpour, and implement it a little differently. Rain is not really all that variable....drop size, and number of drops is pretty narrow, really.

position object, maybe?

EDIT: Also, you can make it so that the fixed array was sizeable, once...or many times. Just dim it again with the new value. The user could request 200 raindrops, and you would just redim the array to that size. Its still fixed, and now is resizeable, just not as dynamically as the previous one.
Posted: 16th Jun 2007 15:21
I've got an idea for 3D-Rain.. maybe it is what you wanted to say and I just didn't get it.

I think it's done in games like splinter cell (part one) this way. I just place 1 or more cylinders around the camera and scroll a rain-texture down.

Look at the example, I think it looks pretty well:

+ Code Snippet
set display mode 800,600,32
sync on : sync rate 60

rem make rain image
ink rgb(30,50,240),0
box 0,0,300,450
set image colorkey 30,50,240
ink rgb(50,70,255),0
for r = 1 to 200
   x = rnd(300)
   y = rnd(450)
   line x,y,x,y+30
next r
get image 1, 0,0,300,450
ink rgb(255,255,255),0
sync : sync : wait key

for o = 1 to 3
   make object cylinder o, -100*o
   texture object o,1
   set object transparency o,1
   scale object texture o, 5*o, 5*o
   scroll object texture o, rnd(100)/100.0, rnd(100)/100.0
   set object light o, 0
next o

rem Matrix
make matrix 1, 1000,1000, 50,50
rem Grass-Texture
for x = 1 to 128
   for y = 1 to 128
      dot x,y,rgb(rnd(40),100+rnd(80),rnd(50))
   next y
next x
get image 2, 1,1,128,128, 1
prepare matrix texture 1, 2, 1,1
randomize matrix 1, 15
update matrix 1

position camera 500,50,100



do
   set cursor 0,0
   print "FPS: ", screen fps()
   control camera using arrowkeys 0, 1,1
   for o = 1 to 3
      position object o, camera position x(), camera position y(), camera position z()
      scroll object texture o, 1, 1.025
   next o
   sync
loop


Thanks for your help jinzai.



Edit: I've updated the example a bit.. here the code with some bad lightning-effects. ^^

+ Code Snippet
set display mode 800,600,32
sync on : sync rate 60
randomize timer()

rem make rain image
ink rgb(30,50,240),0
box 0,0,300,450
set image colorkey 30,50,240
ink rgb(50,70,255),0
for r = 1 to 200
   x = rnd(300)
   y = rnd(450)
   line x,y,x,y+30
next r
get image 1, 0,0,300,450
ink rgb(255,255,255),0
sync : sync : wait key

for o = 1 to 3
   make object cylinder o, -100*o
   texture object o,1
   set object transparency o,1
   scale object texture o, 5*o, 5*o
   scroll object texture o, rnd(100)/100.0, rnd(100)/100.0
   set object light o, 0
next o

rem Matrix
make matrix 1, 1000,1000, 50,50
rem Grass-Texture
for x = 1 to 128
   for y = 1 to 128
      dot x,y,rgb(rnd(40),100+rnd(80),rnd(50))
   next y
next x
get image 2, 1,1,128,128, 1
prepare matrix texture 1, 2, 1,1
randomize matrix 1, 15
update matrix 1


rem Lightning-Sprite
box 0,0,4,4
get image 3, 1,1,4,4, 1
sprite 1,0,0,3
size sprite 1, screen width(), screen height()
hide sprite 1
set sprite alpha 1, 0


position camera 500,50,100



do
   set cursor 0,0
   print "FPS: ", screen fps()
   control camera using arrowkeys 0, 1,1
   for o = 1 to 3
      position object o, camera position x(), camera position y(), camera position z()
      scroll object texture o, 1, 1.025
   next o

   rem Lightning
   if rnd(500)=1
      Lightning = timer()
   endif
   LightTime = timer()-Lightning
   if LightTime<300
      set sprite alpha 1, 255-(LightTime/300.0)*255
      paste sprite 1,0,0
   endif

   sync
loop


Edit2: The same with snow.

+ Code Snippet
set display mode 800,600,32
sync on : sync rate 60
randomize timer()
Snow = 1

rem make rain image
if Snow=1 then ink rgb(255,255,255),0 else ink rgb(30,50,240),0
box 0,0,300,450
if Snow=1 then set image colorkey 255,255,255 else set image colorkey 30,50,240
if Snow=1 then ink rgb(220,222,230),0 else ink rgb(50,70,255),0
for r = 1 to 200
   x = rnd(300)
   y = rnd(450)
   if snow = 1 : box x-1,y-3,x+1,y+3 : else : line x,y,x,y+30 : endif
next r
get image 1, 0,0,300,450
ink rgb(255,255,255),0
sync : sync : wait key

for o = 1 to 3
   make object cylinder o, -100*o
   texture object o,1
   set object transparency o,1
   scale object texture o, 5*o, 5*o
   scroll object texture o, rnd(100)/100.0, rnd(100)/100.0
   set object light o, 0
next o

rem Matrix
make matrix 1, 1000,1000, 50,50
rem Grass-Texture
for x = 1 to 128
   for y = 1 to 128
      col=rgb(rnd(40),100+rnd(80),rnd(50))
      if Snow=1 and rnd(2)=1 then col=rgb(200+rnd(55),200+rnd(55),200+rnd(55))
      dot x,y,col
   next y
next x
get image 2, 1,1,128,128, 1
prepare matrix texture 1, 2, 1,1
randomize matrix 1, 15
update matrix 1


rem Lightning-Sprite
box 0,0,4,4
get image 3, 1,1,4,4, 1
sprite 1,0,0,3
size sprite 1, screen width(), screen height()
hide sprite 1
set sprite alpha 1, 0


position camera 500,50,100



do
   set cursor 0,0
   print "FPS: ", screen fps()
   control camera using arrowkeys 0, 1,1
   for o = 1 to 3
      position object o, camera position x(), camera position y(), camera position z()
      scroll object texture o, 1, 1+(0.25*(1-Snow*0.95))
   next o

   rem Lightning
   if Snow=0
      if rnd(500)=1
         Lightning = timer()
      endif
      LightTime = timer()-Lightning
      if LightTime<300
         set sprite alpha 1, 255-(LightTime/300.0)*255
         paste sprite 1,0,0
      endif
   endif

   sync
loop
Posted: 16th Jun 2007 22:30
Check out the very first challenge in the DBPro Challenges thread - if I remember correctly, it was to make a weather system. There may be some ideas there.
Posted: 16th Jun 2007 23:33
I agree, that's a pretty nice system you have. Yes, I meant something like that, but you have done an excellent job with it!

Yes, I like Splinter Cell, too. I particularly like Michael Ironside doing the interviews on my PS2 version. The rain is nice there, too. I took forever to find the first door, had to swallow alot of smoke....then my kid says, turn around, Dad its right over there!

No problem, I like to see people doing this kind of thing, and your code reads well, and is well written. Thanks for sharing it with us!
Posted: 17th Jun 2007 0:38
I like the effect I made a small change for fun, tell me what you think...

+ Code Snippet
set display mode 800,600,32
sync on : sync rate 60
autocam off

rem make rain image
ink rgb(30,50,240),0
box 0,0,300,450
set image colorkey 30,50,240
ink rgb(50,70,255),0
for r = 1 to 200
   x = rnd(300)
   y = rnd(450)
   line x,y,x,y+30
next r
get image 1, 0,0,300,450
ink rgb(255,255,255),0
sync : sync : wait key

for o = 1 to 3
   make object cylinder o, -100*o
   texture object o,1
   set object transparency o,1
   scale object texture o, 5*o, 5*o
   scroll object texture o, rnd(100)/100.0, rnd(100)/100.0
   set object light o, 0
next o

rem Matrix
make matrix 1, 1000,1000, 50,50
rem Grass-Texture
for x = 1 to 128
   for y = 1 to 128
      dot x,y,rgb(rnd(40),100+rnd(80),rnd(50))
   next y
next x
get image 2, 1,1,128,128, 1
prepare matrix texture 1, 2, 1,1
randomize matrix 1, 15
update matrix 1

position camera 500,50,100
make object plain 999,1,1
hide object 999


do
position object 999,camera position x(),camera position y(),camera position z()
   set cursor 0,0
   print "FPS: ", screen fps()
   control camera using arrowkeys 0, 1,1
   for o = 1 to 3
      if object collision(999,o)=0 then position object o, camera position x(), camera position y(), camera position z()
      scroll object texture o, 1, 1.025
   next o
   sync
loop
Posted: 17th Jun 2007 0:46
Yes, great, I also thought about such a feature, but maybe you should use more than 3 rain-cylinders then, because it's possible to run out of them.
Glad that you all like it.
Posted: 19th Jun 2007 17:02
Wow, that looks nice. Do you use normal sprites? And is it possible to change the wind-direction (because it doesn't really look so..). However, good work, so I think I will just make 3D weather. Although I don't know how I could make the rain-intensity variable.. i could just change the rain-cylinders alpha-value. But that wouldn't look to realistic..
Posted: 19th Jun 2007 17:40
I think this drop-image fits into your demo very well. Looks a bit like a comic.. but not very realistic, right. Do you have a thread about your project anywhere?
Posted: 20th Jun 2007 0:44
Do you think you are going to post your 2D weather-system in the forums? Then I would just do a 3D-system, would be alot less work, I think. Your game looks nice btw, as I already wrote in your thread.