News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

flaming star

Started by stef, December 18, 2005, 09:27:49 AM

Previous topic - Next topic

stef

Hi!

Just a word at begin.
This is finally the last code post of mine.Let's say the reason is the lack of communication. Those retrogame-competition ( I will not take part) made the decision (without an explanation) easier.

But now to the code:
You will need the 'Extended Floating Point Library' by empty in SLIB-Folder
Download:
Extended Floating Point Library (login required)
(extract it into SLIB-folder)

The program below is only semifinished, but works.
It's an app using the "superformula" (by Johan Gielis). This formula calculates the polarcoordinates of points of a curve.

The main parameters are m, n1,n2,n3
By changes this parameters it can draw a lot of different curves

Try
n1=n2=n3= 1 with several values of m ( 1 to 10)
or
n1=n2=n3= 0.3 with several values of m ( 1 to 10)

This is making a starfish:
m#=5
n1#=0.2
n2#=1.7
n3#=1.7

This is a "superellipse"(by Piet Hein)
m#=4
n1#=2.5
n2#=2.5
n3#=2.5

This is preset: It's drawing a flaming star (I think it fits better to time before christmas as a gun)
m#=28
n1#=0.2
n2#=0.5
n3#=0.2

However

MERRY CHRISTMAS!

and HAPPY NEW YEAR!

and GOOD LUCK!

.......and PEACE!

to all of you!

stef

PlayBASIC Code: [Select]
; PROJECT : superformula
; AUTHOR : stef
; CREATED : 11.11.2005
; EDITED : 18.12.2005
; ---------------------------------------------------------------------
;r# = (((abs(cos(m#*angle/4)/a#))^n2#)+((abs(sin(m#*angle/4)/b#))^n3#))^(1/n1#)

#Include "ExtFloat.pba"

;RemStart
minusone#=-1.0
one#=1.0
two#=2.0
four#=4.0
a#=1.0
b#=1.0
;-------------------------------------------mainparameters
; change for other curves
; never use negative values here !!!!!!!!!!!!!!!!!!!!!!!!!
m#=28
n1#=0.2
n2#=0.5
n3#=0.2
;----------------------------------------------------------

ACSet = 1
Degreex = AC(1)
Sinx = AC(1)
Cosx = AC(1)
minusonex =AC(1)
onex=AC(1)
twox=AC(1)
fourx=AC(1)
ax=AC(1)
bx=AC(1)
mx=AC(1)
n1x=AC(1)
n2x=AC(1)
n3x=AC(1)
term1ax=AC(1)
term1bx=AC(1)
term1cx=AC(1)
term1x=AC(1)
term2ax=AC(1)
term2bx=AC(1)
term2cx=AC(1)
term2x=AC(1)
res1x=AC(1)
res2x=AC(1)
rx=AC(1)
xx=AC(1)
yx=AC(1)



CreateExtFloat minusonex
ExtFloat minusonex, minusone#

CreateExtFloat onex
ExtFloat onex, one#

CreateExtFloat twox
ExtFloat twox, two#

CreateExtFloat fourx
ExtFloat fourx, four#

CreateExtFloat ax
ExtFloat ax, a#

CreateExtFloat bx
ExtFloat bx, b#

CreateExtFloat mx
ExtFloat mx, m#

CreateExtFloat n1x
ExtFloat n1x, n1#

CreateExtFloat n2x
ExtFloat n2x, n2#

CreateExtFloat n3x
ExtFloat n3x, n3#

CreateExtFloat term1ax

CreateExtFloat term1bx

CreateExtFloat term1cx

CreateExtFloat term1x

CreateExtFloat term2ax

CreateExtFloat term2bx

CreateExtFloat term2cx

CreateExtFloat term2x

CreateExtFloat res1x

CreateExtFloat res2x

CreateExtFloat rx

CreateExtFloat xx

CreateExtFloat yx


For angle = 0 To 360


CreateExtFloat Degreex

CreateExtFloat Sinx

CreateExtFloat Cosx



ExtFloat Degreex,Float(angle)
SinExtFloat Sinx, Degreex
CosExtFloat Cosx, Degreex
;------------------------------------------------start of superformula-calculation

MulExtFloat(term1ax, mx, Degreex)

DivExtFloat(term1ax, term1ax, fourx)
CosExtFloat term1bx, term1ax
DivExtFloat(term1cx, term1bx, ax)
term1c#=getextfloat(term1cx)
If term1c#<0 Then MulExtFloat(term1cx,term1cx,minusonex)
PowerExtFloat(term1x, term1cx, n2x)



SinExtFloat term2bx, term1ax
DivExtFloat(term2cx, term2bx, bx)
term2c#=getextfloat(term2cx)
If term2c#<0 Then MulExtFloat(term2cx,term2cx,minusonex)
PowerExtFloat(term2x, term2cx, n3x)


AddExtFloat(res1x, term1x, term2x)
DivExtFloat(res2x, onex,n1x)
Login required to view complete source code

thaaks

Cool!
I don't understand what it does and how it does it - but it's fast and results in pretty nice curves :D

Can you tell if  there is some usage of this super formula in games? Would it make sense to calculate waypoints for alien attack waves? Or is it fast enough to draw strange shapes in realtime as game objects? What did you plan to do with it? Or did you just like the smooth curves it can draw?

Sorry to hear that this will be your last source code post. Lack of communication is pretty common in forums. Many people read stuff, reuse stuff and just don't reply.
Or it doesn't fit their current needs and they forget about it.

Also community driven projects often die and are never finished...
...I think the only thing that works in forums is when person A asks for some code fragment or a certain routine and some other persons help with solutions...

In other forums people post complete games/apps and don't get any feedback at all - quite depressing if you spent lots of your time, energy and heart for it...

I hope you'll stay in this forum and give people a helping hand - for me you seem to be pretty smart and it looks like you really got into Play Basic already.
I am still fiddling around and haven't even finished a simple game - that's why I am thinking about joining the retro competition: to start, develop and finish a game with Play Basic.

Cheers,
Tommy

stef

Hi thaaks!

QuoteCan you tell if there is some usage of this super formula in games? Would it make sense to calculate waypoints for alien attack waves? Or is it fast enough to draw strange shapes in realtime as game objects? What did you plan to do with it? Or did you just like the smooth curves it can draw?

The "mainreason" to post this example is "empty" ,who made the library. (He made it after a post of mine). I thought I must present at least one usage of his library.

You can relate this formuladrawing with fractals. Maybe it's useful, maybe not.
I can imagine some use of it in games.You mentioned "waypoints", this is a really good idea. But for now it's future stuff.

The version of superformula-example above is an "old" one, but it works with the current demoversion of PB.
A newer version ( uses only powers-calc of library) is 4 times faster.

Greetings
stef

medwayman

I see you've put out lots of great code examples. Nice work :)
Are you planning on making a game? It would be interesting to see what ideas you have.

stef

Hi!

Of course I'm planning on making a game (a really fantastic one)
The examples are just exercises to get familiar with PB.

At this time I'm working on "watercomputer" (pretty slow,wet and a bit crazy) :)

Greetings
stef

medwayman

It's a good idea to explore the language first.

Look forward to your next work  :)