View Full Version : Working Class for PathSprite + Demo
Donone
11-27-2007, 11:24 AM
Pun not intended.
This requires a minimum of PPL 1.4 beta 5. Nothing less will work.
The final version of PathSprite (except for a vga font issue when run on VGA PPC). A fully working demo Class.
Text file with details.
I hope somebody can learn something of value to them from this, I certainly learned a great deal doing it.
Please report any problems and if you improve it please be good enough to share. Any comments, good or bad, very welcome.
PathSprite: Instantiates a sprite with a travel path of waypoints to visit, in any direction, pre-defined by user.
1. Any number of waypoints may be set.
2. Can be started at any waypoint in the list.
3. Speed is variable 9 to 0. zero is the fastest (default).
4. Options allow to reverse, stop or repeat the path when finished.
5. Events can be used to control itself or other spawned sprites.
6. Visibility can be on/off
7. New paths can be loaded provided a test for 'STILL' is carried out first.
8. Can be stopped at any waypoint.
Each sprite may be accessed to use the standard sprite features as follows where "hSp$" is the internal Sprite Handle...
SetSpriteCollide(objname.hSp$,Collide);
If animation, gravity etc. is to be used then change g_SetMainLoop(1); to 0 in WinMain.
Enjoy playing with the demo, especially the events triggering actions.
Then add your own methods/properties/events.
*************************
Please will you assist me to decide how rubbish my Acer VGA PPC is, by roughly timing how long it takes for the blue sprite to do one complete rectangle.
My desktop takes 4 seconds and my WM5 VGA is 30 seconds, disastrous.
*************************[br]1196162641_231_FT0_mpathsprite.zip
kornalius
11-27-2007, 12:41 PM
Amazing job Donone. I am happy to see that all the efforts we put together with Eric as been put to good use.
Thank you for sharing this with us.
matteo.m
11-27-2007, 09:47 PM
hi Donone, very nice piece of software! I'm impressed about what ppl can do!! I'm not really good about oop so your code is for sure a gift to me to learn more about class and object, so big thanks... For another things i like the way you put comments in the source that remind me cobol programming ;) Also again thanks to Alain and Eric to make this happen :)
Donone
11-28-2007, 11:39 AM
My thanks for the comments.
I shall be posting a diagrammatical (flow chart-ish) tutorial to go with this Class, maybe tomorrow in case it would help anybody. It might be easier than trying to de-CODE.
matteo.m
11-28-2007, 08:57 PM
a flow-chart it will make easier to umderstand the code
Donone
11-29-2007, 03:14 PM
I attach a diagram explaining the flow of the PathSprite Class.
I hope it helps anybody not too sure about it. It only covers the Sprite Procedure and associated routines for home made Events. The other properties etc should be self explanbatory.
This should be viewed along with the code and could of course be printed.
It is on A4 British paper size but would probably print OK on Letter.
It is a single sheet in two forms, Adobe pdf and doc for MS Word (2003 was used).[br]1196349263_231_FT8087_pathsprite-docs.zip
matteo.m
11-30-2007, 04:07 PM
Thankd Donone i'm going to study this weekend!!
lopez1de
09-26-2008, 10:19 AM
This isn't working with 1.52 anymore?
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Cannot use in expression at 'IIF' (103,5)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [; expected at ',' (103,13)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Cannot use in expression at 'IIF' (103,17)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [; expected at ',' (103,25)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Invalid number of output arguments (0) at '=' (103,4)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Syntax error at '1' (103,26)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [: or , expected at ')' (103,29)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Syntax error at ')' (103,29)]
error: (c:\ppl\1196162641_231_ft0_mpathsprite\mclasspaths prite.ppl) [Syntax error at ')' (103,30)]
Donone
11-08-2008, 02:21 PM
This was written with 1.4 and I believe worked with 1.5??
There appears to have been changes with the IIF() statement recently and it appears that it is a void and also the ',' were replaced with ';'. I have tried that but it didn't cure because I don't think IIF() returns anything anymore (which would seem to make it pointless).
I have changed to IF/ELSE and got as far as the correct display appears etc. but something else has been changed in PPL because it just sits there looking at me.
Perhaps some kind soul who has been around recently and knows what changes have taken place, could point me in the right direction.
Run MTestClass.
Thanks
reposted here as it is so far...
Donone
11-08-2008, 05:52 PM
Problems solved, it now works with 1.52
It was a combination of IIF() not now working, self.sgn() which no longer worked (self???)I replaced that with the new 'sign()' function.
I don't know how to remove the previously posted file mPathSprite2008 so have posted the new one (mPathSprite11-2008).
I hope it is of use/interest to someone.
kornalius
11-08-2008, 09:07 PM
Donone,
Please point me to the error with the Self.sgn() line? I will review your code and make sure Self is working like it should in 1.53.
Donone
11-09-2008, 08:33 AM
Thanks for coming in on this Alain. I thought it best to try to fix this just in case anybody got anything from it.
I am not 100% sure but surmise.
I discovered that IIF had changed from comma to semicolon separater and edited.
I still got the problem. I read the help which indicated that the IIF was now a void return.
Previously I had a routine to get the sign of a variable; r$=iif(n$<0;-1;iif(n$>0;1;0)); (now commented on line 110 MClassPathSprite.ppl) which used the return from IIF.
This means that the void only permits the IIF to carry out an action such as in the help file (ShowMessage) where it should (IMHO) give a return.
Accordingly changed the code to IF/ELSE (Lines 102 etc. now also commented).
That didn't totally cure the fault and I was pointed to where my routine 'sgn' was called. (Lines 71-74) which did read Spr.x$=Spr.x$+self.Sgn(xCount$); etc. etc.
I discovered the new 'Sign' function in help and changed it to what is there now and hey presto.
Now, I don't know for sure whether self was the specific problem or a quirk in the order in which I did things or what, but there it is.
[EDIT] Just to be sure... this morning I put IF/ELSE and RETURN(r$) back and then put self.sgn back and the display just froze on the screen.
I also really think IIF should give a return :)
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.