Jump to content
IGNORED

Moving a sprite through a Maze, Extended Basic


LASooner

Recommended Posts

 

So after adding 4 more points of character detection, he moves the maze pretty good, the only areas where he's having trouble is the ends of the walls, but I put IF/THEN statements in the movement subroutines to handle those positions and it's working fairly well. If the character gets really close to the wall he's moving slower but not stopping, and I'm not opposed to this behavior as it simulates wall scraping a bit, so I may just leave it. Most importantly adding the extra detection passes hasn't made that much of a speed hit compared to just 4. I took Mathew180's suggestion of removing the interim variable.

 

I use TIdBit so this is my detection pass

_MOVERETURN:


	_COLMAP:	CALL GCHAR(INT(MY/8)+1,INT(MX/8)+1,MZ1)
					IF MZ1=32 THEN GOSUB _LEFT
					IF MZ1=16 THEN GOSUB _LEFT
					IF MZ1=17 THEN GOSUB _LEFT
					IF MZ1=18 THEN GOSUB _LEFT
					IF MZ1=19 THEN GOSUB _LEFT
					IF MX>33 AND MY>33 THEN _COLMAP1
						FOR A=36 TO 45
							IF MZ1=A THEN GOSUB _WEBLEFT
						NEXT A
			
	_COLMAP1:	CALL GCHAR(INT(MY/8)+2,INT(MX/8)+1,MZ2)	
					IF MZ2=32 THEN GOSUB _LEFT
					IF MZ2=16 THEN GOSUB _LEFT
					IF MZ2=17 THEN GOSUB _LEFT
					IF MZ2=18 THEN GOSUB _LEFT
					IF MZ2=19 THEN GOSUB _LEFT
					IF MX>33 AND MY>33 THEN _COLMAP2
						FOR A=36 TO 45
							IF MZ2=A THEN GOSUB _WEBLEFT
						NEXT A	
			
	
	_COLMAP2:	CALL GCHAR(INT(MY/8)+1,INT(MX/8)+3,MZ3)
					IF MZ3=32 THEN GOSUB _RIGHT
					IF MZ3=16 THEN GOSUB _RIGHT
					IF MZ3=17 THEN GOSUB _RIGHT
					IF MZ3=18 THEN GOSUB _RIGHT
					IF MZ3=19 THEN GOSUB _RIGHT
					IF MX>33 AND MY>33 THEN _COLMAP3
						FOR A=36 TO 45
							IF MZ3=A THEN GOSUB _WEBRIGHT
						NEXT A
						
	_COLMAP3:	CALL GCHAR(INT(MY/8)+2,INT(MX/8)+3,MZ4)
					IF MZ4=32 THEN GOSUB _RIGHT
					IF MZ4=16 THEN GOSUB _RIGHT
					IF MZ4=17 THEN GOSUB _RIGHT
					IF MZ4=18 THEN GOSUB _RIGHT
					IF MZ4=19 THEN GOSUB _RIGHT
					IF MX>33 AND MY>33 THEN _COLMAP4
						FOR A=36 TO 45
							IF MZ4=A THEN GOSUB _WEBRIGHT
						NEXT A
		
	_COLMAP4:	CALL GCHAR(INT(MY/8)+1,INT(MX/8)+1,MZ5)
					IF MZ5=32 THEN GOSUB _UP		
					IF MZ5=16 THEN GOSUB _UP
					IF MZ5=17 THEN GOSUB _UP
					IF MZ5=18 THEN GOSUB _UP
					IF MZ5=19 THEN GOSUB _UP
					IF MX>33 AND MY>33 THEN _COLMAP5
						FOR A=36 TO 45
							IF MZ5=A THEN GOSUB _WEBUP
						NEXT A
						
	_COLMAP5:	CALL GCHAR(INT(MY/8)+1,INT(MX/8)+2,MZ6)
					IF MZ6=32 THEN GOSUB _UP		
					IF MZ6=16 THEN GOSUB _UP
					IF MZ6=17 THEN GOSUB _UP
					IF MZ6=18 THEN GOSUB _UP
					IF MZ6=19 THEN GOSUB _UP
					IF MX>33 AND MY>33 THEN _COLMAP6
						FOR A=36 TO 45
							IF MZ6=A THEN GOSUB _WEBUP
						NEXT A					
										
	_COLMAP6: 	CALL GCHAR(INT(MY/8)+3,INT(MX/8)+1,MZ7)
					IF MZ7=32 THEN GOSUB _DOWN
					IF MZ7=16 THEN GOSUB _DOWN
					IF MZ7=17 THEN GOSUB _DOWN
					IF MZ7=18 THEN GOSUB _DOWN
					IF MZ7=19 THEN GOSUB _DOWN
					IF MX>33 AND MY>33 THEN _COLMAP7
						FOR A=36 TO 45
							IF MZ7=A THEN GOSUB _WEBDOWN
						NEXT A
	
	_COLMAP7: 	CALL GCHAR(INT(MY/8)+3,INT(MX/8)+2,MZ8)
					IF MZ8=32 THEN GOSUB _DOWN
					IF MZ8=16 THEN GOSUB _DOWN
					IF MZ8=17 THEN GOSUB _DOWN
					IF MZ8=18 THEN GOSUB _DOWN
					IF MZ8=19 THEN GOSUB _DOWN
					IF MX>33 AND MY>33 THEN _LIMITS
						FOR A=36 TO 45
							IF MZ8=A THEN GOSUB _WEBDOWN
						NEXT A


Just wondering about the speed of the program and all the IF THEN in that program with a GOSUB:

_COLMAP:	CALL GCHAR(INT(MY/8)+1,INT(MX/8)+1,MZ1)
					IF MZ1=32 THEN GOSUB _LEFT :: GOTO _HERE
					IF MZ1=16 THEN GOSUB _LEFT :: GOTO _HERE
					IF MZ1=17 THEN GOSUB _LEFT :: GOTO _HERE
					IF MZ1=18 THEN GOSUB _LEFT :: GOTO _HERE
					IF MZ1=19 THEN GOSUB _LEFT
_HERE					IF MX>33 AND MY>33 THEN _COLMAP1
						FOR A=36 TO 45
							IF MZ1=A THEN GOSUB _WEBLEFT
						NEXT A

If MZ1=32 it takes longer to get to the MX<>33 then if MZ1=19 as it has to check all the IF THEN lines when we know MZ1=32

so that is 3 lines we know do nothing but waste time in program checking someting we know is false.

 

I think this would add up to some real delay in a XB program, not so much in Assembly but it all adds up eventually.

Edited by RXB
Link to comment
Share on other sites

Yeah, I'm trying to get it all working first, then make performance adjustments, It's already changed quite a bit since I posted that, I'm no longer checking all four sides, I check the direction that the joystick is pulled, this sped things up quite a bit, as it's only doing 2 GCHARs per loop if the Joystick is moved, it's created fewer IF/THEN statements.

 

Thanks for sanity checking stuff like this. It will help when I'm looking to speed things up before compiling. The faster it runs in XB the smoother it will be once compiled.

 

I have the directional firing from the player working, once I get the robot firing I'll start working on sprite collisions. Then working on the higher level robots ability to chase the player.

 

I'm really happy to see the progress I've made so far.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...