https://drive.google.com/file/d/1Gp_2Ta-rLHJVle3jXImhkI1iZsUkJiR3/view?usp=sharing
And here we go.
There's a flap that has a writeup of what is happening, but basically, I
took the last version, made a copy of the main player, removed controls and
set up an 'auto movement' script that utilizes the collision detection.
Then I modified the playfield's script to 'tell all contents HANDLE
PATROL'. Nothing is pre-scripted to move any specific way, so you can move
all of the objects around and they'll react to walls, you can change their
speed and what direction(s) they're moving in, etc. Obviously, the larger
you make them, the slower the update to the playfield will be since there's
a pixel economy to worry about. However, it shouldn't be especially
concerning on a newer computer. It is for the computer I'm working with
which is why I made things relatively small. I suppose the next version
will demo making special objects, collectables, etc. Presumably, I could
remake the pacman example since in this way, no matter what the
'player/hero' bumps into, you can grab information about that object since
it learns what it's element number is and then you can have the playfield
set it's cursor directly to the object to send a message to it
specifically.
I might try that, or something similar. It will be interesting to see how
it handles a lot of similar objects in that way. Also, I'll probably start
adding graphics and demo how to layer onto these rectangles graphics so
that you can animate them without having to copy all of the scripts to a
sketch object.
This has been rather fun, and it's rewarding to finally get something of
this nature running relatively nice in Etoys. I've been wanting to use it
for a while now for simple, retro-style action games and have made small
tests here and there regarding things like using a Book as a world-map
(i.e. touching the edges of a page with your hero turns to specific pages
for multi-screen worlds) etc. One day I'll bring all of these things
together coherently...hopefully.
In the meantime, enjoy this demo.
https://drive.google.com/file/d/1Gp_2Ta-rLHJVle3jXImhkI1iZsUkJiR3/view?usp=sharing
Post by Jeremy LandrySo after thinking a bit, I decided to take a different route to accomplish
this, though the ending demo is a lot different (I plan on going further
with this, so expect this demo to get bigger until it's something that's
less demo and more 'it's just a fun game' or something to that extent).
At any rate, I was thinking about how Etoys graphics and 'overlaps any'
works and thought about what I'm really after; I don't want to find out
AFTER something happens that two objects are overlapping. Plus when
detecting whether things overlap, I believe Squeak goes into some maths to
determine areas that overlap etc, which again aren't what I'm interested
in; I'm interested in obstructing movement of objects and knowing which
objects are being 'touched' when obstructing other moving things.
So I went back to the drawing board and didn't use 'overlaps any' at all.
Instead, I decided to think about 'what are the likely ways to eliminate
checking anything at all if I can help it?' So for instance if something is
moving to the right, then I don't need to check things behind it at all and
whether it might touch them. So from there I began writing some scripts to
that do their best to check only things that absolutely will lead to a
collision; at any point if any of these checks fail, the rest of the checks
aren't performed so that the process can quickly move on to the next object
for inspection of whether the moving object has to be worried about it or
not.
Included is a demo. It explains maybe in a bit more detail what this can
do. By using this method of checking for touching objects, I can also
detect which side another object was approached from as well. In the demo,
the blocks change color depending on whether they were touched vertically
or horizontally by the 'Hero' object with a simple script (all of the
'walls' are siblings of the object Thing and so editing Thing will send all
of the other walls that functionality too).
Again, I think it performs rather speedy, even my my old 2008 ultra
portable 1.4 Ghz with virtually no video accelleration at all, I'm getting
high frame rates even with checking 18 objects vs. the other try I uploaded
which has many fewer objects and ends up checking a lot more about what is
happening in the playfield and interactions.
Hopefully this is useful to someone and/or ends up becoming something
possibly embedded into the Etoys scripting tiles at some point, though I
cannot realy think of a universal way to put this sort of thing in there
where it's of any use :p
https://drive.google.com/file/d/1w-ty8C6yLsLmx6M1pYGbx6bMUPmUtbAg
/view?usp=sharing
Next I will add clones of the 'Hero' with scripted automated movements to
recreate the tests I already posted and I suspect they will operate much
smoother and more accurately to boot.
Post by Jeremy LandryI figured out why special events weren't working the way I had them set
up. In order for the events to be scheduled properly, so to speak, they
have to occur individually and be taken care of individually. So instead
of 'Tell All Contents (SCRIPT)', I used a Do (Number of Objects)
Times/PlayerAtCursor Do (then event is triggered and handled for a single
pair of objects)/Cursor IncreaseBy1. This all happens each tick so it
appears as if it's simultaneous. It's, so far, fastest for dealing with
collisions, I will post another project soon with demos/examples.
Also, my copy of Etoys5 starts with 'Custom User Events' checked inthe
preferences. I don't ever make changes to etoys friendly options...I'm not
sure what is going on there...
Post by Jeremy LandryHere's a book of experiments with various ways of implementing 'OVERLAPS
ANY (OBJECT)' along with commentary for each experiment. Maybe someone will
find it useful. Overall, at least on my slow machine, page 2 seems to
perform the fastest. I explain how each of the 7 versions is set up as the
idea evolves across the pages.
https://drive.google.com/file/d/1JopwojV1KcQar27BkZbrKSjufnk
VX9j1/view?usp=sharing
I think in the end, having something very specific in mind with regards
to motion is probably far more useful than creating 'general behaviors', at
least where realtime behavior and many moving objects is concerned. As
well, the things I was moving about are a little large compared to what I
intend to move since there's a 'pixel limit' per frame which is hardware
dependent as well as dependent on whether the screen is being scaled or
not. I ran my experiments with no screen scaling at all.
If anyone has any further ideas on ways to cut screen update time or
further narrow the amount of 'observations' that happen during a single
update of all objects on screen, etc. let me know and I will try them out
and maybe add them to this book/project for others to learn from and use
for their own stuff.
Post by Bert FreudenbergPost by Jeremy LandryWhat is the intended use for 'triggering object' tile?
I don't know. Never used that tile (it's hidden unless eToyFriendly is
disabled).
Reading the code it indeed is intended to find the object that
triggered that event / script (meaning the object mentioned in the
tellAllSiblings tile).
- Bert -
_______________________________________________
Beginners mailing list
http://lists.squeakfoundation.org/mailman/listinfo/beginners