We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am working on a 3D game, just for fun, and I spent a while figuring out how I could look around. I finally created what I thought was my solution, but occasionally when the cam passes over two certain points, it freaks out and locks into this seizure thing and wont let you move the cam most of the time. I've been working with these view calculations for a while now because they work(most of the time), but it's starting to bother me. In the code, I made lines to show the axes as well as where the cam target is. When the cam target(blue line) passes over the red line, that is where the seizure occurs, although sometimes you have to move it back and forth for a bit to get it to happen. (I already tried this out on multiple computers. It is a problem in the code.)
The other problem: collision detection. In the game, there are platforms that are already built, and platforms that you make. This was also something I thought I had figured out till some small bug manifested itself. When you build platforms very close together where they overlap, building upwards(like a staircase), if you try to walk up the "stairs," you don't go up, but rather walk through the other stairs and fall off the first step. However, if you build downwards, once again very close together where they overlap, and then go up the stairs, then it works. >:(
If I did not clarify something well enough, let me know and I will try to further explain it. Here is the code. I have to put it in comments since it makes this too long.(note: I'm sorry if this is a lot :( I already trimmed it down a ton.) A platform preview can be formed by pressing shift. You can look around while pressing shift to choose where to built it. You build the platform by pressing "b" while shift is pressed.
Comments
I apologize, but neither the Ctrl+k was working, nor the C button :( not sure why that is. I made sure there were blank lines before and after.
EDIT: switched computers and ctrl+k worked. Thanks, I didn't know about formatting it in the IDE.
this is the "wall.png" called for in the code.
Yikes, you rly should use more arrays. Those plat01 to plat19 & brick1 to brick9 are fit candidates!
I'm relatively new to processing(as well as coding in general) :P so I'm not quite certain what you mean by that. Aren't I already using them in that situation? at least for the plat1-19? Any help with my code in general is welcome(seriously, what should I be doing?), but help about the issue at hand is more welcome. ;)
EDIT: oh wait a second, are you saying it is possible to have an object array? Never tried it. I will when I have time.
Yup! Besides the 8 primitive types, any object type is valid for arrays as well:
Otherwise, arrays in Java would be very limited! :P
That is quite handy when there are a lot of 'em, and in the whole program, there is. Thanks for mentioning that. I applied it to my code(thank heavens for Ctrl+f). Although I don't understand why the PShape or really any basic array has to declare one too many or else it errors with "out of bounds," while the object array is fine. I understand that there are seven shapes, but shouldn't PShape[6] including [0] be enough? (ya know... 0,1,2,3,4,5,6)
EDIT: oh wait lol, even the object array errors out on me if at [18].
I updated the code above, it now has the arrays we discussed, as well as more condensed sections and minor changes. Hopefully it is now pleasing to your eye ;)