PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Important changes

The compiler in the latest version of PPL (pre-release beta 8) (which will come out very soon) has gone through a few little but very important changes:

1. The ^ operator is now used (just like C) as a bitwise-exclusive OR.

2. The @ is replacing the operator ^ old behavior.

3. |=, &= and ^= are now possible.

4. A bunch of the sprite's functions have been replaced or removed with the much easier SetSpriteOptions(), AddSpriteOption(), DelSpriteOption() and SpriteOptions() functions.

Instead of having functions like:

Code:
SetSpritePaused(sprite$, true);
SetSpriteFixed(sprite$, false);


You can now easily add or remove status flags using the:

Code:
AddSpriteOption(sprite$, SO_PAUSED);
DelSpriteOption(sprite$, SO_FIXED);
Hi Kornalius, I've been checking back every now and then on how you are going with PPL and it's been very interesting to watch it grow. One question - why do you use "$" for variables?
Variables are easier to spot this way for the users. Since PPL doesn't declare variables, it's also easier for the compiler to analyze the code this way.
If most os the sprite functions will be handled with these new functions, I would suggest that you acronym these long names for easy typing

AddSpriteOption might be ASO or AddSO
DelSpriteOption might be DSO or DelSO

Just an idea
Also,

1) would you use this with say, SetSpriteCollide. Seems like that would be hard.

2) how would you retrieve these properties?
Hi,

I can always add

#define AddSO AddSpriteOption
#define DelSO DelSpriteOption

in the gameapi.ppl.

To retrieve the options, SpriteOptions() is used. Then you check with (options & SO_WHATEVER).

SetSpriteCollide is not an option per say. It is a string, therefore cannot be used with the options.
ok
Kornalius,

On the subject of the new operators, will the old text version of XOR still work? Could you please update the precidense page in the .CHM file also?

Brad
Hi bmanske,

Yes the XOR is still there too.

The help file has been updated.
The more I am playing around with spriteoptions() the more cumbersome I am finding it. Before I could simply type:

If (SpriteVisible(b$))
blah blah blah;
End;

Now I cannot see an easy way of doing this.

Also, I added a few options to Mario$ in your example. Each time I did a ShowMessage(Spriteoptions(mario$)) all I get back are numbers. How do I effectively use this? I can't use

if (SpriteOptions(b$) == SO_VISIBLE)

can I?

next I was looking over the help file at SetSpriteOptions() and had a questions. What if I want the sprite's shape to be rectangle. I used to be able to simply use SpriteShape(). The only flag I see is SO_OVAL. A user may find themself contantly checking the help file because they can't remember what flags to use. The only other solution I see is to use SetSpritePhysics() and set everything, even though I just wanted to set the shape.

I really thought the old way was more intuitive. Just my lowly opinion :)
Hi,

Use AddSpriteOption(mario$, SO_VISIBLE) to make it visible and DelSpriteOption(mario$, SO_VISIBLE). The Sprite options is just a integer value.

To check wheter an option exists:

if ((SpriteOptions(mario$) & SO_VISIBLE) != 0)
ShowMessage("Sprite is visible");
end;

----------------------------------------------------
If you want the sprite's shape to be rectangle, just remove the SO_OVAL option from the options.

DelSpriteOption(sprite$, SO_OVAL);
Gosh, it just doesn't seem intuitive to me.

1) look at the difference between the code:

if ((SpriteOptions(mario$) & SO_VISIBLE) != 0)
ShowMessage("Sprite is visible");
end;

and

If (SpriteVisible(b$))
ShowMessage("Sprite is visible");
End;

2) Again, look at the difference between the code:

DelSpriteOptions(mario$, SO_VISIBLE);

and

ShowSprite(mario$,true);

3) I could keep going but I hope it is clear enough which ones read and write easier and a new user would understand better and be able to jump write in.
Nothing stops you from creating a few functions in the gameapi.ppl :wink: :

Code:
func SpriteVisible(sprite$)
return ((SpriteOptions(Sprite$) & SO_VISIBLE));
end;
...
I had a feeling I would get a response like that :) .
I just think new users would find it SOO much easier the way it was. Very intuitive.

Not to mention I have to change all my code around for the game I was working on :P

Maybe there are some hidden advantages to having it the new way that I am not aware of.
The advantages were:

1. Reduce the size of ppl.exe by removing around 20 functions.

2. Storage space per sprite is reduced from about 10 fields to only 1 field.

3. In one function call you can set multiple attributes: SetSpriteOptions(Sprite$, SO_VISIBLE | SO_FIXED | SO_OVAL);

I am sure there are more... :)

The Windows API work this way too, you should get use to it. Start now, it might be harder to learn, but once you will understand it perfectly you will see the advantages.
ok