Thursday, May 29, 2008

XeO3: Script Docs complete!!!

Well, I've finished the 1st pass of the scripting docs!! Didn't take too long at all, I'm quite pleased about that. I do still have a couple of examples to do, but they can be added anytime really....

I also just realised I should really add a MoveLoop command since 90% of move commands are surrounded by For/Next loops!

       PFor   50
Move -2,0
pNext


This takes 6 bytes. But if I were to do this....

       MoveLoop  50, -2,0


It would only take 4. Now, 2 bytes doesn't seem like much, but I have 91 loops in level 1 at 2 bytes per loop which makes 182 bytes saved. Not only that but you'd have less typing, and the code would just look nicer!

;-----------------------------------------------------------------------------
; tear drops...
;-----------------------------------------------------------------------------
Drop_1:
DRIFT -1
Move 0,1
Move 0,1
Move 0,2
Move 0,2
Move 0,2
PFOR 4
Move 0,3
PNEXT
PFOR 5
Move 0,4
PNEXT
PFOR 6
Move 0,5
PNEXT
PFOR 200
Move 0,6
PNEXT
KILLSPRITE


becomes....

;-----------------------------------------------------------------------------
; tear drops...
;-----------------------------------------------------------------------------
Drop_1:
DRIFT -1
Move 0,1
Move 0,1
Move 0,2
Move 0,2
Move 0,2

MoveLoop 4, 0,3
MoveLoop 5, 0,4
MoveLoop 6, 0,5
MoveLoop 200, 0,6
KILLSPRITE


Which is much nicer!! Not only that.... But that would give you VERY simple loops in loops.... So a Square path that would look like this...

  PFOR 90
Move -4,0
Move -4,0
Move -4,0
Move -4,0
Move 0,4
Move 0,4
Move 0,4
Move 0,4
Move -4,0
Move -4,0
Move -4,0
Move -4,0
Move 0,-4
Move 0,-4
Move 0,-4
Move 0,-4
PNEXT
KILLSPRITE


becomes - THIS! (which obviously saves even MORE memory!)


  PFOR 90
MoveLoop 4, -4,0
MoveLoop 4, 0,4
MoveLoop 4, -4,0
MoveLoop 4, 0,-4
PNEXT
KILLSPRITE

1 comment:

Iapetus said...

Great stuff.

I have read all you wrote about the scripting commands and code example.

Waiting anxiously for the day when you start to add stuff to the code section of the wiki, to know how you implemented the script engine, sprites engine.... and a large ETC. :)

cheers