The basic syntax for defining a plain sprite is as follows:
// Create a sprite object
mySprite = sprite load "filename.png"
// Move the sprite from time 0 to 100ms from (0,0) to (10,20)
[0,100] mySprite move (0,0) (10,20)
// From 100ms until 500ms, repeatedly move the sprite up then down again
[100,500] mySprite
[0,50] move (10,20) (10,10)
[50,100] move (10,10) (10,20)
// Shorthand of above
[100,500] mySprite = sprite load "filename.png"
[0,50] move (10,20) (10,10)
[50,100] move (10,10) (10,20)
// Or even
[100,500] sprite load "filename.png"
[0,50] move (10,20) (10,10)
[50,100] move (10,10) (10,20)Functions
// Create a function "abs"
func abs x
if x > 0
x
else
-x
// Use the function
[abs -10,20] mySprite move (20,20)
// Explicit arg name
abs x: -10
// Without parentheses
abs -10
// Extending a class
func sprite bounce direction distance
midTime = (startTime + endTime) / 2
[startTime, midTime] move relative (0, 0) (cos direction * distance, sin direction * distance)
[midTime, endTime] move relative (cos direction * distance, sin direction * distance) (0,0)
// Use extension (all below do the same thing)
[0,300] mySprite bounce 90 40 // Bounce up a distance of 40
[0,300] mySprite bounce direction: 90 distance: 40
[0,300] mySprite bounce 90 distance: 40
[0,300] mySprite bounce distance: 40 90Boolean parameters
func enum pretty? fancy? nice?
if pretty
"I'm pretty!"
if fancy
"I'm fancy!"
if nice
"I'm nice!"
"Fail"
enum pretty // I'm pretty!
enum pretty nice // I'm pretty!
enum fancy // I'm fancy!
enum false fancy: false nice: true // I'm nice!
enum false // Fail
enum // FailVarargs (and currying)
func sprite moveToCentre args...
move (320, 240) args...
[10,200] mySprite moveToCenter relative
Comments
Hey Ph0X, I see your point.
Hey Ph0X,
I see your point. Have you used the
withstatement in some programming languages? Basically, you can transform:into:
This is essentially what I am doing with my syntax. I'll consider a way of joining our syntaxes so both can be used nicely.
All you did is pretty much
All you did is pretty much add brackets, and turned a 3line code into 5 line. I personally don't like grouping by sprite. I'd rather have it by timeline, but even there, you can still put all the Sprite1.FUNCTIONS groups together if you want.
//sprite1
Sprite1.move
Sprite1.rotate
Sprite1.fade
//sprite2
Sprite2.move
Sprite2.move
Sprite2.fade
What if you could do both? Call a single function, or call multiple functions if you need to.
Yes, that is correct, and
Yes, that is correct, and yes, I did intend on having both. I'll work on it ...
laternow. How's this?Ph0X
Sprite1 = "amazing_image.png"
[0,100] SpriteSample.move( (x1,y1) , (x2,y2) [, easing=1] )
Further on, you can have
SparkleGroup = (Sparkle1, Sparkle2, Sparkle3)
[0,500] SparkleGroup.rotate( Angle1, Angle2 [, easing = 0 [, degree=0 ]] )
Should also be able to have variables, conditions and loops
Variables should be able to use certain information about the gamestate, such as number of x/50/100/300, current health, etc
Conditions should be able to test things such as IsDoubleTime or IsFailing, and of course, use variables to do the tests too
Loops, we already have, but it would be great if we could have while loops too, that use conditions, as in
while NumberOf300 < 10:
[0,100] Sprite_YouCanDoBetter.size( 1, 2 )
[100,200] Sprite_YouCanDoBetter.size( 2, 1 )
then:
Sprite_YouCanDoBetter.alpha( 1, 0 )
and shit like that
Post new comment