01-02-2010 02:22 PM
EchoWolf wrote:Now, on to LabView. No, I do not plan to copy>paste someone's code, because the purpose of this assignment is to learn the functions of things such as clusters, arrays, shift registers, indexing and local variables. I know what they are, but I've never really used arrays or clusters before, or at least not that I can remember.
Why would you need local variables for this??? 😮
The pong you attached acts more like an incomplete "breakout", and not "pong". Too much code for my taste, it is probably cleaner to use arrays instead of numerous scalar shift regsiters.
Here's a quick draft that just bounces a ball around in a box. See if it makes sense? 😉
Maybe it can give you some ideas.
01-02-2010 02:51 PM
Those were just the things he wanted us to get the hang of. The assignment was NOT to make a pong game, but to make A game. Any game we wished. It could be something very simple, or a little more complex. I'm a big fan of classic gaming, and I wanted to make pong. I thought it would be somewhat challening, but after reading a little about it, the claims are that it is a very simple game. I figured why not try it?
As I want to keep this game basic, I don't think I'll worry about having different ball speeds yet. Just simple launch of the ball from origin, and have it bounce around on its own at first. Then add a paddle to allow for interaction. If I can get that far (again, with help, I very much hope), I would be quite happy.
The code is excellent, but I have a few questions, if you'd be willing to indulge a complete novice >.<
Ok, the "DrawAreaSize" module, what does that actually accomplish? I see that the outputs are converted through a "cluster to array" err...thing... haha. I am sorry, I am feeling really stupid at the moment for beeing such a noob at this. I can program, really, I can! Just not at a professional level. Just a student here >.<
Anyways, I am trying to figure out the functions of everything here. My guess is that this gives me values for the position of the ball?
Also, what is the purpose of the "Uniform White Noise" module? Is that what creates the random motions for the ball movement?
Again, I apologize for my inexperience. I can only ask that you have some patience with me.
01-02-2010 03:07 PM
Scratch some of those silly speculations over there. I dropped some probes and removed a few things I didn't want (like the little sound generator, though it does add a cool effect, don't get me wrong).
So, the DrawAreaSize module gives me the actual dimensions of the field. Do you divide that by two to set the initial ball location in the middle? Also, what function actually generates that ball? Or is it already part of the picture?
01-02-2010 03:40 PM
EchoWolf wrote:
Do you divide that by two to set the initial ball location in the middle? Also, what function actually generates that ball?
There is the picture function to draw a filled circle at a given xy position. That draws the "ball".
Another option would be to use an xy graph as in your old example. It will not work well to draw the paddles, though.
Here is a quick example using an xy graph indicator instead. As you can see, With a few small modifications, my code is fully scaleable, so no code changes are needed if you want more balls.
(Of course, if you want the balls to collide with each other, it would be a bit more complicated ;)).
01-02-2010 04:24 PM
I thik I prefer your previous one better. I was able to recreate some parts of the code (I feel a bit accomplished for being able to figure out how to without just copy/pasting) ^.^
My question is that, if I wanted to have a set speed for the ball without having those random values you place in, how much of that bottom portion of the code can I remove? And, what part of that code reverses the X and Y values upon collision?
I think for today, I just want to be able to get the ball to bounce around within the frame.
On a side note: what is the point of the "wait" timer in this program?
Also, this is the "bottom part of the code" that I am referring to:
I am guessing that I could remove the "GenerateWhiteNoise" module and the case structure that it goes through later?
01-02-2010 04:51 PM - edited 01-02-2010 04:56 PM
EchoWolf wrote:My question is that, if I wanted to have a set speed for the ball without having those random values you place in, how much of that bottom portion of the code can I remove? And, what part of that code reverses the X and Y values upon collision?
I think for today, I just want to be able to get the ball to bounce around within the frame.
On a side note: what is the point of the "wait" timer in this program?
...
The code gets random speeds at start and whenever the bump button is pressed. If you want fixed speeds, create an array constant with two elements. Set the values in some range -1..1. of course it will now be the same whenever you run the program, which is a bit boring. 😉
The reversal happens in the small FOR loop. Whenever the new x or y is out of bounds, we negate the corresponding speed. The "in range and coerce" function outputs an array which is FALSE for all values that are not in range. We loop over all speeds and flip the ones that have an out of bounds x or y.
If you would remove the wait, the loop would spin as fast as the computer allows, probably millions of times per second. The wait makes sure that the loop iterates at a constant and reasonable rate. Dataflow dictates that the loop iteration cannot complete until all code in it has completed. The wait takes the longest and thus determines the loop rate. Why don't you try to remove the wait and see what happens? Now put the wait back! 😉
01-02-2010 05:05 PM - edited 01-02-2010 05:13 PM
Ah, this is all quite ingenious! Ok, I got the basic loop part done. I removed the case structure and the "bump" button, so the speed is now always the same (perhaps making it boring, but this is my first visual game!).
Also, that one wire carries both x AND y values (the one that comes out of the DrawAreaSize). Is that why it's different color from the typical blue wires that carry integers? Or is blue signifying that it is an integer and not a double?
Before I remove the wait to test that, should I save my file and prepare to Ctrl+Alt+Del to prevent my computer from freezing? What is the break command(or the keyboard shortcut for it, rather) in LabView?
And how does one edit these posts on here? I cannot find the edit button anywhere >.< nvm, found it!
I'm sorry for asking so many questions, but I am extremely grateful for your help! I went from being incredibly frustrated this morning, to being rather excited for this program all thanks to you! You're a real savior!
The computer I am running it on is a lapt top with a CoreDuo processor. Luckily it's an XP, so it doesn't eat THAT much CPU. haha.
However, this one here is a quad core with Vista >.>
01-02-2010 05:46 PM
EchoWolf wrote:
Also, what is the purpose of dividing the values that come out of the DrawAreaSize by 2?
as you guessed already, to start in the center...
(nothing will freeze if you remove the wait. Just stop the vi as usual.... )
01-02-2010 05:58 PM - edited 01-02-2010 05:58 PM
Thank you very, very much, sir! I will be back tomorrow to ask for help with implementing an interface to put in a paddle, and allow for it to be controlled with the up and down keys. And, because that sounds simpler to me, I am betting that it will be harder than the bouncing ball part. >.<
One last question for tonight though:
Is this part here just computations to redraw the "ball" each loop iteration?
01-02-2010 07:23 PM
Ok, this is my code so far. It is a simplified re-creation of the one you gave me earlier. The only problem I am having is that connection that you see missing between the picture module and the ArrayToCluster converter. It gives me the error of connecting clusters with different data types, saying that I am trying to connect a "cluster of 9 elements" to a "cluster of 2 elements."
What did I do wrong?