To be sure, wall collisions aren't the issue here. The fairly new "move slice with wallchecking" command is the reason I started this project in 2017. The problem is that it doesn't account for NPC (slice-slice) collisions. The current scripts just check if there will be a collision with an NPC on the next step, then stops the player if so. It's very barely adequate but lacks any sliding against slices you're colliding with.
The problem I couldn't wrap my head around was in determining how much distance the player has left of their movement. Currently, slice-slice collision detection returns a boolean value.
I appreciate the code, but I don't really understand bit shifting in general, let alone how it would be accomplished in hspeak. I can't figure out what any of those variable names are meant to represent, either.
Pixel-Walker v2.0: Testers Needed!
Moderators: Bob the Hamster, marionline, SDHawk
If you're having trouble with the geometric approach, you could try the guessing approach. It's a generic technique called binary search. Sometimes it's very effective. It's used to solve square roots among other things.slice-slice collision detection returns a boolean value
On the other hand, it's not as effective as the "bothering TMC" technique, because you know, science has its limits.
----
I just thought that if you can assume the value you're looking for is a small number, you could also adapt the line drawing algorithm. Instead of drawing a pixel you do a collision check and you keep going until it returns true. You could optimize it using fixed point math, but it may also work without if you're clever with the formulas.
----
So I think I've found an incorrect but acceptable way to handle collisions on the corners of the pass map. It relates to the other code I've posted before. If you don't understand it of if you don't think it's even hspeak, just ignore it for now. Eventually I'll take some time to tie everything together with an explanation.
Code: Select all
# north east corner
if (not(pbs & pbbn) && not(pbs & pbbe)) then (
if ( \
read pass block(pbx + 1, pby) & pbbn || \
read pass block(pbx, pby - 1) & pbbe \
) then (
pbdx = abs(blpx - pb2x)
pbdy = abs(blpy - pb1y)
pbd = pbdx + pbdy
if (pbd < blrad) then (
if (pbdx < pbdy) then (
blpx -= blrad - pbd
blvx = -fix24:mul(blvx, 50)
) else (
blpy += blrad - pbd
blvy = -fix24:mul(blvy, 50)
)
continue
)
)
)
As it is, it's not enough for a minigolf game but it's enough to let slices be guided into door pockets, which is useful.
Last edited by lennyhome on Wed Apr 22, 2020 5:04 am, edited 5 times in total.
Lenny: heh, as usual I didn't see most of that reply because you added it later in an edit. Note to reader: Lenny later posted Sub-Pixel-Walker v0.1: Testers not needed with some explanation.
~~~
I finally realised (someone told me) that pixel-walker v2.3 still shows the same script error that v2.0-2.2 did if you use Test Game in Gorgonzola, because of the change to "get hero slice". An error about an invalid slice handle 0 in createobject.
For v2.0-2.2 the workaround was to make two small fixes to the scripts: in animateObjects in animate.hss change "for(i, 0, 3) do(" to "for(i, 0, 0) do(" and in createHeroObjects in util.bas change "for(hero, 0, 3) do(" to "for(hero, 0, 0) do(".
However v2.3 now has caterpillar party support and uses "get hero slice" in many more places, so that won't work.
BTW I notice that
is wrong, since addHero returns a party slot, not a rank. It should be
(Removed the no longer needed slot<4 since reserve heroes have slices too)
Except actually it should new add hero trigger instead so that adding heros from eg textboxes works too.
Also I noitce the moveObject script uses a "hero" variable which is never set, so equal to 0.
~~~
I finally realised (someone told me) that pixel-walker v2.3 still shows the same script error that v2.0-2.2 did if you use Test Game in Gorgonzola, because of the change to "get hero slice". An error about an invalid slice handle 0 in createobject.
For v2.0-2.2 the workaround was to make two small fixes to the scripts: in animateObjects in animate.hss change "for(i, 0, 3) do(" to "for(i, 0, 0) do(" and in createHeroObjects in util.bas change "for(hero, 0, 3) do(" to "for(hero, 0, 0) do(".
However v2.3 now has caterpillar party support and uses "get hero slice" in many more places, so that won't work.
BTW I notice that
Code: Select all
plotscript, addHeroWithAttributes, who, begin
variable(slot)
slot := addHero(who)
if(slot < 4) then(
writeObject(getHeroSlice(slot), obj:originSet, getHeroPicture(slot))
)
end
Code: Select all
plotscript, addHeroWithAttributes, who, begin
variable(slot)
slot := addHero(who)
writeObject(getHeroSliceBySlot(slot), obj:originSet, getHeroPicture(slot))
end
Except actually it should new add hero trigger instead so that adding heros from eg textboxes works too.
Also I noitce the moveObject script uses a "hero" variable which is never set, so equal to 0.
Thanks for pointing these out. I've been fully preoccupied with other projects lately, but these are pretty important bugs to get sorted out. I'll try to address them soon, and hopefully have time to add a feature of some sort to make it feel like a worthwhile update.
My pronouns are they/them
Ps. I love my wife
Ps. I love my wife
v2.4 is now available for download
Those bugs should now be fixed. Doing so created some other bugs, but I think I ironed all of those out as well. I could be wrong, and this update could have introduced (or failed to address) bugs I didn't notice with my testing. I wasn't able to add anything else to the scripts, other than also fixing party swapping. You could call that a feature if you're liberal with the term.
Those bugs should now be fixed. Doing so created some other bugs, but I think I ironed all of those out as well. I could be wrong, and this update could have introduced (or failed to address) bugs I didn't notice with my testing. I wasn't able to add anything else to the scripts, other than also fixing party swapping. You could call that a feature if you're liberal with the term.
My pronouns are they/them
Ps. I love my wife
Ps. I love my wife