01-09-2018 03:55 PM
Hello all.
I'm currently creating a space invaders style game for a university coursework, I've so far managed to create player movement, firing and enemy movement. I'm now a little stuck on how to basically have the enemy 'be destroyed' upon contact with the bullet from the player. I've tried to use a comparison of the position property nodes and used an AND gate to provide the source for a case structure, but this doesn't seem to work. I'm not sure whether this is bad code, or whether the bullet misses it by a few pixels and the event doesn't run, but I'm not sure how to provide the bullet with a larger area than one pixel location. Any help would be appreciated.
01-09-2018 04:11 PM
What you've described all sounds like good possibilities as to why your code might not work.
But it is impossible to provide any help based on just a written description and without seeing any of your actual code.
01-09-2018 04:19 PM
Apologies, I've attached a screen grab of the current structures. I've managed to make some small progress in that as soon as the Top value is equal then the case structure executes, and I'm now going to attempt to link this with the left property as well and see if I can get some semblance of a working program.
01-09-2018 04:23 PM
I've also amended the increment that the enemy image moves to even increments in an attempt to make it easier to marry up the positions by limiting the possible values and having a predictable path.
01-10-2018 02:21 AM
Hi Jamie,
do you think you need so many local variables (or "value" properties)?
Don't you think you could put the "game engine" into a statemachine? (I imagine states like "draw playfield", "move objects", "check collisions", "update player statistics" - just to mention a few…)
And keep all relevant data in a cluster, stored in a shiftregister?
01-10-2018 07:35 AM
Thank you for the advice, I will give your suggestion a go and see if I can get it to work! I've been pretty much teaching myself as I've been developing this as my experience with labview is rather limited, and it has been quite difficult to find resources to use!
01-10-2018 10:14 AM
You have a race condition with Player Bullet that may cause the bullet to "skip" over the enemy. As Gerd mentioned, you have too many property nodes.
01-10-2018 05:09 PM - edited 01-10-2018 05:38 PM
@JamieMoly97 wrote:
Apologies, I've attached a screen grab of the current structures. I've managed to make some small progress in that as soon as the Top value is equal then the case structure executes, and I'm now going to attempt to link this with the left property as well and see if I can get some semblance of a working program.
OK, none of your code makes any sense. What's up with the FOR loop at the bottom, for example?
Please attach the actual VI so we get a better idea what you are trying to do.
All you probably need is a 2D array indicator of flat booleans, with one state colored transparent (or background color). Now overlay a 2D picture with transparent background over it with the same size. Draw the ball using this function. Keep the array in a shift register and switch elements to transparent on collisions (you do the math!). No property nodes or local variables needed at all. For ideas how to bounce the ball, have a look at this old code, for example (posted here).
01-11-2018 10:16 AM
Thank you all for your advice! It's been very useful, and I've managed to get it working, now to attempt to integrate it to the main program.
Once again, thank you!
Kind Regards,
Jamie