BASIS Plugin Tutorial

The place for any Hollywood tutorials
Post Reply
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

BASIS Plugin Tutorial

Post by Bugala »

This is not official in any way, this is just what I figured out on how to use BASIS plugin in Hollywood, and some of my conclusions might even be wrong.

I am using following sample code included with BASIS:

Code: Select all

@VERSION 1, 0

@DISPLAY {Width = 800, Height = 600}

count = 0

Function p_MainLoop()
    basislib.UpdateAnim(1, .033)

	Cls(#BLUE)
	TextOut(#CENTER, 30, "# animations: " .. basislib.GetNumAnims(1))
	TextOut(#CENTER, 45, "Playing: " .. basislib.GetAnimIndex(1))
	DisplayBrush(1, #CENTER, #CENTER)
	Flip
	count = count + 1
	If count > 75
		basislib.ChangeAnimIndex(1, ((basislib.GetAnimIndex(1) % basislib.GetNumAnims(1)) + 1))
		count = 0
	EndIf
EndFunction

SetFontColor(#WHITE)
TextOut(#CENTER, #CENTER, "LOADING...")

EscapeQuit(True)
LeftMouseQuit(True)

CreateBrush(1, 612, 512, #BLUE, {AlphaChannel = 1})

; Very rough way to get relative paths in parent folders....
success = basislib.LoadSticki(1, "/Res/Dragon.ske")   ; amiga from BinAmiga
If success = 0 Then success = basislib.LoadSticki(1, "../Res/Dragon.ske")   ; from BinWin or BinLinux
If success = 0 Then success = basislib.LoadSticki(1, "//Res/Dragon.ske")   ; amiga from Src HollywoodMal
If success = 0 Then success = basislib.LoadSticki(1, "../../Res/Dragon.ske")   ; other from Src HollywoodMal

TextOut(#CENTER, #CENTER - 40, success)
basislib.SetAnimIndex(1, 4)
basislib.SetHotSpot(1, 0, 498, 320)
basislib.SetTransform(1, 0, 14, 14)

BeginDoubleBuffer()

SetInterval(1, p_MainLoop, 33)
Repeat
	WaitEvent
Forever

EndDoubleBuffer()
basislib.LoadSticki(1, "../Res/Dragon.ske")

This is to load BASIS character from chosen place. number is ID. So there can be character 1, 2, 3...

Notice that if ID is 1, then Hollywood brush 1 is used for this BASIS character.


basislib.SetAnimIndex(1, 4)

I suppose this is next thing to do after you have loaded BASIS character. This will initialize character ID 1 and set him into ANIM/Position 4.

- Notice that each character can have several animations/positions. Animations and positions are same thing. I am using position word just to make it easier to understand. Practically a position would be animation with only one frame. Normally each position has at least to key frames from which all the movement is calculated from. You can see my game example, in that the dragon has 5 different animations, one for walking, one runnning, one puffing standing, one puffing sitting, the fifth one i forgot and its not in use in the game.

Anyway, BASIS handles from moving from one animation to another so that it fills all the gaps between movement to go for example from running to sitting position and other way round.


basislib.SetHotSpot(1, 0, 498, 320)

Hotspot, just like in other Hollywood objects hotspot setting. I forgot the numbers already, but i think it goes following: ID, special, x, y) Special meaning something im not quite sure how it works in Basis yet, just that when you changed from one number ot other, character might flip to other edges or something, and sometimes seen fully, sometimes not. I guess using 0 is pretty safe number.


basislib.SetTransform(1, 0, 14, 14)

I think this had to do with actually attaching the character to a bursh (permanently, so only needed to do once)

numbers: ID, special, xsize, ysize

Special might be same as in SetHotSpot


basislib.UpdateAnim(1, .033)

This is where the magic happens. This will make the actual animation.

numbers: ID, amount.

When you make keyframes, you for example set that first keyframe is at location 0, then next keyframe is at location 0. This "amount" tells how big a skip you are going to make on that animation. Bigger the number, bigger the amount of movement.

In that example game of mine "Clone pacman faces the dragon" I am increasing this amount to bigger and bigger all the time making it look like the dragon and pacman are speeding up.


basislib.GetNumAnims(1)

Tells how many different animations/positions ID specified character has


basislib.GetAnimIndex(1)

tells which animation number is currently being played of specified (ID) character


basislib.ChangeAnimIndex(1, 2)

Numbers: ID, anim number

This will change the animation/position being played of character. In this case Character ID 1 changes to animation number 2.



Notice that you also need to Create a Brush of a size that can display your BASIS anim first before you can display BASIS characters.

Im not sure if double buffer and flip is needed, but i guess that could be a good idea, especially since you are wont be using layers, but brushes, and using CLS (Clear Screen) is recommended option.

And of course, dont forget to DisplayBrush(ID, x, y), since thats where the BASIS characters current anim frame is.


If i understood correctly, technically BASIS works so that first you create a rectangle brush. To this brush BASIS characters each frame will be created each time you update BASIS caharacter, and then you simply use DisplayBrush to display this brush that contains the current frame of the BASIS character.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: BASIS Plugin Tutorial

Post by Bugala »

There is now some documentation in HTML format for Basis Hollywood plugin in newest release of Basis in here:
http://achild.wikidot.com/basis

That documentation of commands is in "Demos" package, not in the main program itself.

Dont also forget that you can still try to donate to speed Basis development on kickstarter:
http://www.kickstarter.com/projects/145 ... ion-system

There is now only 32 hours left, and it seems its going to fail.

But just showing your interest and support, even with just that 1 dollar donation will probably make the developers very happy and acknowledge Amiga better.

Although you probably wont even need to pay even that dollar since it is only barely 10 percent funded from the minimum amount in which case no one pays nothing.
Post Reply