Pixel-Walker v2.0: Testers Needed!

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

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.
My pronouns are they/them
Ps. I love my wife
lennyhome
Slime Knight
Posts: 115
Joined: Fri Feb 14, 2020 6:07 am

Post by lennyhome »

slice-slice collision detection returns a boolean value
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.
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 &#40;pbd < blrad&#41; then &#40;
			if &#40;pbdx < pbdy&#41; then &#40;
				blpx -= blrad - pbd
				blvx = -fix24&#58;mul&#40;blvx, 50&#41;
			&#41; else &#40;
				blpy += blrad - pbd
				blvy = -fix24&#58;mul&#40;blvy, 50&#41;
			&#41;
			continue
		&#41;
	&#41;
&#41;
In total one needs to do 4 corner cases like the above and 4 wall cases like in my previous post. It's long, it's boring and I'm still loking for ways to make it substantially shorter. I'm also still looking for a way to make the corner geometrically round instead of geometrically strange.

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.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

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

Code: Select all

plotscript, addHeroWithAttributes, who, begin
    variable&#40;slot&#41;
    slot &#58;= addHero&#40;who&#41;
    if&#40;slot < 4&#41; then&#40;
        writeObject&#40;getHeroSlice&#40;slot&#41;, obj&#58;originSet, getHeroPicture&#40;slot&#41;&#41;
    &#41;
end
is wrong, since addHero returns a party slot, not a rank. It should be

Code: Select all

plotscript, addHeroWithAttributes, who, begin
    variable&#40;slot&#41;
    slot &#58;= addHero&#40;who&#41;
    writeObject&#40;getHeroSliceBySlot&#40;slot&#41;, obj&#58;originSet, getHeroPicture&#40;slot&#41;&#41;
end
(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.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

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
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

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.
My pronouns are they/them
Ps. I love my wife
Post Reply