Computer Science Canada Array Subscript is out of Range |
Author: | kane8290 [ Thu May 17, 2012 12:32 pm ] |
Post subject: | Array Subscript is out of Range |
Can someone look at this coding? It's an attempt at psudo-raycasting, but the array I'm using to map the pixel coordinates on the map file is acting very weird. |
Author: | Dreadnought [ Thu May 17, 2012 12:52 pm ] |
Post subject: | Re: Array Subscript is out of Range |
Say your player is at the rightmost edge of the map. You check pixels to his right. What happens? |
Author: | kane8290 [ Thu May 17, 2012 12:54 pm ] |
Post subject: | RE:Array Subscript is out of Range |
I don't have anything to prevent that. But, right at the start, you are in the middle of the map (ish), so the problem shouldnt be poping up instantly. BTW, you did follow that coding alright, right? I was think of reposting a version with more comments in it. |
Author: | kane8290 [ Thu May 17, 2012 1:03 pm ] |
Post subject: | RE:Array Subscript is out of Range |
Actually, thanks. That did work. I changed the move commands around to prevent you from getting that close to the edges. But the issue is still a matter of it not drawing the walls when you move. |
Author: | jr5000pwp [ Thu May 17, 2012 1:03 pm ] |
Post subject: | RE:Array Subscript is out of Range |
Your game moves the player 1 unit per loop, you start at 32 and you begin getting out of bounds errors at 58-59. That is 26 refreshes, which, if coded well, should be almost instantaneous. As for fixing the errors, you will have to makes sure your PlayerX, PlayerY, BeamX, and BeamY variables do not exceed your 64 by 40 map limit. This can be done using simple if statements to prevent character movement past a certain point. |
Author: | kane8290 [ Thu May 17, 2012 1:15 pm ] |
Post subject: | RE:Array Subscript is out of Range |
Again, the issue of player movement has been resolved. As of right now, the player cannot be within 5 units from boundry. But that doesn't really solve the problem of the walls not being created. My teacher is under the impression that something is not right in the Map_Scan procedure. Ideas? |
Author: | Dreadnought [ Thu May 17, 2012 2:40 pm ] |
Post subject: | Re: Array Subscript is out of Range |
What do you mean by "the walls are not being created"? Are you drawing something that appears to not show up? |
Author: | kane8290 [ Thu May 17, 2012 4:52 pm ] |
Post subject: | RE:Array Subscript is out of Range |
Yes, if you were to follow the program, you would see that the program is supposed to draw rectangles on screen youing information gathered by the other parts of the program (namley the Map_Scan procedure). |
Author: | Dreadnought [ Thu May 17, 2012 6:22 pm ] |
Post subject: | Re: Array Subscript is out of Range |
Well, there is a red line at the left of the screen. Why don't you try to find out what the value of BeamX is when you call Draw_Wall. |