Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - mike_g

Pages: 1 2 [3]
41
Blitz / Pompom - Amoeba things[BB2D]
« on: January 06, 2007 »
A function I am working on that draws fuzzy things. It became a bit more complex than I initially expected so I might rewrite it useing types intead of arrays. I also plan on adding rotation and improving the speed. Anyway here it is:
Code: [Select]
;GLOBAL ARRAYS NEEDED
Dim fuzzer(10, 360), fuzzdir(10, 360)
;---------------------------------------------------------------------;
;***************************** DEMO **********************************;
;---------------------------------------------------------------------;
Graphics 1024, 768
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Color 200, 50, 50
FUZZ_INIT(1, 100, 360)
FUZZ_INIT(2, 100, 360)
FUZZ_INIT(3, 100, 360)
FUZZ_INIT(4, 100, 360)
FUZZ_INIT(5, 100, 360)
While Not KeyHit(1)
Cls
FUZZY_CIRCLE(1, 300, 300, 100, 160, 50, 5, 1)
FUZZY_CIRCLE(2, 800, 500, 100, 360, 50, 5, 0)
FUZZY_CIRCLE(3, 550, 200, 50, 50, 40, 3, 0)
FUZZY_CIRCLE(4, 550, 200, 50, 50, 10, 1, 0)
FUZZY_CIRCLE(5, 400, 600, 100, 20, 10, 1, 0)
Flip
Wend
;---------------------------------------------------------------------;
;*************************** FUNCTIONS *******************************;
;---------------------------------------------------------------------;
Function FUZZ_INIT(number, intense, fuzz)
For i = 1 To fuzz
fuzzer(number, i) = Rand(0, intense)
Next
End Function
;------------------------------;
Function FUZZY_CIRCLE(number, cx, cy, rad, fuzz, intense, vibration, randy)
angstep# = Float(360) / Float(fuzz)

first_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
first_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
this_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
FUZZ_MOVE(number, 1, intense, vibration, randy)

LockBuffer
For i = 2 To fuzz
deg# = deg# + angstep#
last_x = this_x
last_y = this_y
FUZZ_MOVE(number, i, intense, vibration, randy)
this_x = (cx - (rad +fuzzer(number, i)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, i)) * Sin(deg#))
Line last_x, last_y, this_x, this_y
Next
Line this_x, this_y, first_x, first_y
UnlockBuffer
End Function
;-------------------------------;
Function FUZZ_MOVE(number, i, intense, vibration, randy)
If fuzzdir(number, i) = 0
fuzzer(number, i) = fuzzer(number, i) + vibration +Rand(0, randy)
Else
fuzzer(number, i) = fuzzer(number, i) - vibration -Rand(0, randy)
EndIf

If fuzzer(number, i) >= intense
fuzzdir(number, i) = 1
Else If fuzzer(number, i) <= -intense
fuzzdir(number, i) =0
EndIf
End Function

42
Blitz / Getting sound volume-pitch levels[BB2D]
« on: January 06, 2007 »
I am thinking about making a music visualiser since it would be a cool way to stick a load of vector graphics stuff together. I would like to be able to time the effects with the music. Now I havent used any of the Blitz sound commands as of yet so I had a peek at the command list. Theres commands in it to set sound volume and pitch but seemingly none to get their level. Am I missing something? Is there anyway I can get this data?     

43
Projects / Space balls
« on: January 04, 2007 »
Just a little old school shoot em up I made. Never got around to completely finishing it, but it has some nice fetures. Get it Here

44
Useful links / Cobra Demo Released
« on: January 03, 2007 »
Just incase any of you guys dident know, demo for the Cobra programming language is available.

I am having a poke about with it at the moment and thought I'd mention it. Link Here O0

45
Blitz / Rounded Rect Function[BB2D]
« on: January 02, 2007 »
Heres a rounded rect function I made with a little animated demo.

The first 4 parameters are same as the standard rect command.

The parameter "round" should be between 0 and half width or height, whichever is shortest. This dtermines how rounded the coerners are. Setting it higher gives some bizzare looking effects.

The col parameter is the argb colour. I might also add a fill parameter too sometime.
Code: [Select]
inc = 1
SetBuffer BackBuffer()
While Not KeyHit(1)
Cls
ROUNDED_RECT(10, 10, 100, 100, r, $FFFFFF)
r = r + inc
If r >= 50 Or r <=0 Then inc = -inc
Flip
Wend

Function ROUNDED_RECT(x_pos, y_pos, width, height, round, col)
   ;DRAW CORNERS
   d = 3 - ((round) Shl 1)
   x = 0
   y = round
   cx1 = x_pos + round: cy1 = y_pos + round
   cx2 = x_pos +width- round: cy2 = y_pos + round
   cx3 = x_pos +width- round: cy3 = y_pos + height- round
   cx4 = x_pos +round: cy4 = y_pos + height- round

   LockBuffer
   Repeat
  ;TOP LEFT CORNER
      WritePixel cx1 - x, cy1 - y, col
      WritePixel cx1 - y, cy1 - x, col

  ;TOP RIGHT CORNER
      WritePixel cx2 + x, cy2 - y, col
      WritePixel cx2 + y, cy2 - x, col
 
      ;BOTTOM RIGHT CORNER
  WritePixel cx3 + x, cy3 + y, col
  WritePixel cx3 + y, cy3 + x, col

  ;BOTTOM LEFT CORNER
  WritePixel cx4 - x, cy4 + y, col
  WritePixel cx4 - y, cy4 + x, col

      If d < 0 Then
         d = d + (x Shl 2) + 6
      Else
         d = d + ((x-y) Shl 2) + 10
         y = y - 1
      End If
      x = x + 1
   Until x > y
   UnlockBuffer
   
   For x = x_pos+round To x_pos+width-round
WritePixel x, y_pos, col
   Next
   For x = x_pos+round To x_pos+width-round
WritePixel x, y_pos+height, col
   Next
   For y = y_pos+round To y_pos+height-round
WritePixel x_pos, y, col
   Next
   For y = y_pos+round To y_pos+height-round
WritePixel x_pos+width, y, col
   Next
End Function

46
Blitz / Some particle FX[BB2D]
« on: December 30, 2006 »
Ive been coding in Blitz for about a year now, but only just got round to having a go at doing particle effects. Theres some pretty amazing stuff on this site. Makes me feel kinda dumb. Anyway heres my attempt. Its kinda like a slinky thing that follows the mouse around.
Code: [Select]
Graphics 1024, 768
Global particles = CreateImage(GraphicsWidth(), GraphicsHeight())
Global count, oldtime, fps ;for fps
Global mode
Global col_timer, col_change
SeedRnd MilliSecs()

Type particle
Field x#, y#, id, ang#, spd
;For colour effects
Field r, g, b; rf, gf, bf
;for circle particles. start size and expand rate
Field rad#, expand#, expand_max
End Type

Global rf =5
Global gf =5
Global bf =5

SetBuffer BackBuffer()
While Not KeyHit(1)
Cls
If mode = 0
NEW_BURST(MouseX(), MouseY(),10)
CIRCLE_PARTICLES(0)
Text 460, 0, "MOVE THE MOUSE"
If mousehit(1) Then mode = 1
COL_CHANGE()
Else
If Rand(0, 2) = 0 Then NEW_BURST(Rand(0, 1023), Rand(0, 768),Rand(10, 30))
CIRCLE_PARTICLES(1)
t=t+ 1
If t > 100
mode = 0
t=0
EndIf
EndIf

DrawImage particles, 0, 0
FPS()
Flip
Wend

;---------------------------;
Function NEW_BURST(x_pos, y_pos, parts)
a_step# = Float(360)/parts
test = a_step#
For i = 1 To parts
p.particle = New particle
p\x = x_pos
p\y = y_pos
p\ang# = angle#
angle# = angle# + a_step#


p\expand = 0.1
p\rad = 0.1
p\expand_max = 10
p\spd = 1
p\rad = 0.1
p\expand_max = 30
p\spd = 1
If mode = 1 Then p\expand = Float(Rand(1, 5))/10

p\r = 255
p\g = 255
p\b = 255
Next
End Function
;---------------------------;
Function CIRCLE_PARTICLES(fill)
SetBuffer ImageBuffer(particles)
Cls
LockBuffer
For p.particle = Each particle
If p\x < -rad Or p\x >= GraphicsWidth()+rad Or p\y < -rad Or p\y >= GraphicsWidth()+rad
Delete p.particle
Else
If p\rad# < p\expand_max Then p\rad# = p\rad# + p\expand#


If p\r >= rf Then p\r = p\r - rf
If p\g >= gf Then p\g = p\g - gf
If p\b >= bf Then p\b = p\b - bf
col = (p\r Shl 16) + (p\g Shl 8) + p\b

p\x = p\x +Cos(p\ang)*p\spd
p\y = p\y +Sin(p\ang)*p\spd
If fill = 0
CIRCLE(p\x, p\y, p\rad, col)
Else
F_CIRCLE(p\x, p\y, p\rad, col)
EndIf
If col <= (rf Shl 16)+(gf Shl 8)+bf Then Delete p.particle
EndIf
Next


UnlockBuffer
SetBuffer BackBuffer()
End Function
;---------------------------;
Function CIRCLE(cx, cy, rad, col)
inc# = Float(360/(rad*Pi*2))
steps = 360/inc#
For i = 0 To steps
x = (cx - rad * Cos(deg#))
y = (cy - rad * Sin(deg#))
If x >= 0 And x < GraphicsWidth() And y >= 0 And y < GraphicsHeight()
WritePixelFast x, y, col
EndIf
deg# = deg# + inc#
Next
End Function
;---------------------------;
Function F_CIRCLE(cx, cy, rad, col)
inc# = Float(360/(rad*Pi*2))
steps = 90/inc#
For i = 0 To steps
x1 = (cx - rad * Cos(deg#))
y1 = (cy - rad * Sin(deg#))

x2 = cx+cx-x1
y2 = cy+cy-y1

If x1 < 0 Then x1 = 0
If x2 > 1023 Then x2 = 1023
If y1 < 0 Then y1 = 0
If y1 > 767 Then y1 = 767
If y2 < 0 Then y2 = 0
If y2 > 767 Then y2 = 767

For x = x1 To x2
WritePixelFast x, y1, col
Next
For x = x1 To x2
WritePixelFast x, y2, col
Next
deg# = deg# + inc#
Next
End Function
;---------------------------;
Function FPS()
Text 0, 0, "FPS: "+fps
time = MilliSecs() - oldtime
count = count + 1
If time >= 1000
fps = count
count = 0
oldtime=MilliSecs()
EndIf
End Function
;---------------------------;
Function COL_CHANGE()
col_timer = col_timer + 1
If col_timer = 10
col_timer = 0
If col_change = 0
rf = rf - 1
If rf = 0
col_change = col_change + 1
EndIf
Else If col_change = 1
rf = rf + 1
gf = gf - 1
If gf = 0
col_change = col_change + 1
EndIf
Else If col_change = 2
bf = bf - 1
gf = gf + 1
If bf = 0
col_change = col_change + 1
EndIf
Else If col_change = 3
rf = rf - 1
gf = gf - 1
bf = bf + 1
If rf = 0
col_change = col_change + 1
EndIf
Else If col_change = 4
rf = rf + 1
bf = bf - 1
If bf = 0
col_change = col_change + 1
EndIf
Else If col_change = 5
bf = bf + 1
gf = gf + 1
If bf = 5
col_change =  0
EndIf
EndIf
EndIf
End Function

Pages: 1 2 [3]