LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a really basic pong game for a beginner

Hello.  I've read through a couple of threads on here dealing with making a game of pong in LabView, but in them the users had questions with far more complex aspects of the program than I want to deal with.  I am a beginner programmer in LabView with limited experience in Java and Visual Basic programming.  I was tasked with creating a game over winter break, and now that I finally have some time (this weekend that is), I decided that I'd make a really simple game of pong.  However, I have seriously overestimated the difficulty of this for a beginner who has very limited knowledge of Lab View.

I ask you to please have some patience with me.

I know what I want to do, and just need help inplementing it.

 

Here is the idea for my design to keep it as simple as possible:

-Create a field (I am not sure what to use for this, but from my reading it appears that some sort of a picture output is needed, but I cannot find that anywhere).

-Set up some simple function that can output the dimensions of this field to use with collision tracking.

-Create a ball that can be tracked by the program.

-From my reading I understand that the simplest way to "bounce" the ball off the sides appears to simply reverse the X velocity of the ball when it strikes the vertical boundaries and the Y velocity when it strikes the horizontal boundaries.

-Insert some sort of a "paddle" that the user can control with the left and right arrow keys.

 

 

Now, as I have mentioned I am a beginner with approximately one month maximum knowledge of this software, spread over about a year.  I want to take things slow.  So for starters, would anyone be willing to walk me through creating a visual output for this and creating a ball that will bounce off all sides?

If I can at least get that far for now, then I can move on (with help I hope!) of inserting an interactive interface for the "paddle."

 

I have found some LabView code for a simple game like this, but it also includes a score keeping loop as well as an "automatic play" option, and I am attempting to wade through all that code to find the bones of it to help me with this, but due to my inexperience, this might thake a lot of time.

 

I thank you for any and all help anyone may be able to provide.

 

0 Kudos
Message 1 of 34
(13,941 Views)

here I hope this helps you:

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 34
(13,923 Views)
Harold, did you write that VI yourself, or did you find it somewhere? If you wrote it yourself, do you not understand the concept of not turning this forum into a homework writing service? The poster clearly indicated this was a homework assignment. I have no problems offering tips and guidance, but just outright giving them answers is something I think is just wrong.
0 Kudos
Message 3 of 34
(13,900 Views)

actually altenbac wrote this when I was trying to get better with arrays

 

sorry about that I would hope the person who created this thread would not just copy and paste the code.(you know like a mature person)

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 4 of 34
(13,885 Views)

Well, the OP indicated that he already found some pong code here, so we have to assume that he read this thread.

 

So what's the point of attaching my version here again without any credit or even a link to the old thread? 😮

 

 

0 Kudos
Message 5 of 34
(13,879 Views)

EchoWolf wrote:

-Create a field (I am not sure what to use for this, but from my reading it appears that some sort of a picture output is needed, but I cannot find that anywhere).


 Wel, there is the picture indicator in the picture palette. In newer versions it's called "2D picture". The palettes have a search function. Using the palette search function is a basic LabVIEW skill that you should know. If you've seen the example for the other discussion, it uses a 2D boolean array indicator. The boolean array is only recommended for a monochrome very low resolution display.


EchoWolf wrote:

-Set up some simple function that can output the dimensions of this field to use with collision tracking.

-Create a ball that can be tracked by the program.


That seems backwards. Properly programmed, the code always knows the dimension and the ball position. The program generates, (not tracks!) the ball movement. Of course you need to do some range checking on the ball position to see when it collides with the walls.

 


EchoWolf wrote:

-From my reading I understand that the simplest way to "bounce" the ball off the sides appears to simply reverse the X velocity of the ball when it strikes the vertical boundaries and the Y velocity when it strikes the horizontal boundaries.


Of course you could make it more realistic by keeping track of three ball parameters: x, y, spin. 🙂


EchoWolf wrote:

-Insert some sort of a "paddle" that the user can control with the left and right arrow keys.


Pong is typically played with the up-down arrow keys.


EchoWolf wrote:

Now, as I have mentioned I am a beginner with approximately one month maximum knowledge of this software, spread over about a year.


LabVIEW knowledge is not measured in time units. What did you do during that month? 😮 Did you attend some lectures, study tutorials, wrote some programs?


EchoWolf wrote:

So for starters, would anyone be willing to walk me through creating a visual output for this and creating a ball that will bounce off all sides?

I have found some LabView code for a simple game like this, but it also includes a score keeping loop as well as an "automatic play" option, and I am attempting to wade through all that code to find the bones of it to help me with this, but due to my inexperience, this might thake a lot of time.


Start with the posted example and delete all the controls and indicators that you don't want, then surgically remove all code with broken wires. 😉

 

Alternatively, start from scratch: Create your playing field. Easiest would be a 2D classic boolean array that is all false. Use initialize array to make it once. Now use a loop to show the ball as a function of time.

 

Start with a random ball position. to display it, turn one of the array elements true before wiring to the array indicator using replace array subset.

 

Keep a shift register with xy positions and xy velocities and update the positions as a function of the velocities with each iteration of the loop. Do range checking and reverse the velocieis when a edge is encountered.

 

What LabVIEW version do you have?

0 Kudos
Message 6 of 34
(13,872 Views)

well Altenbac, I never took credit for writing the pong program I just put it there for help as my post indicated, and then my next post clearly states that you wrote it. (like at the end of a long paper when you put in a bibliography.)

 

I put it on this forum to make sure he saw it. (that is all)

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 7 of 34
(13,863 Views)
Who is Altenbac? 😄
0 Kudos
Message 8 of 34
(13,850 Views)
lol A l t e n b a c h:)
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 9 of 34
(13,842 Views)

Ok, maybe I should explain a little before first.  I am one of the new programmers on my team.  The only experience I've had with LabView so far was the little introduction program we were walked though that was a PDF file with simple step-by-step instructions on how to make a small robot recognize the colors of two balls (1 red and 1 blue) and pick up the blue one.

 After that, I helped write the autonomous mode for the big robot that mainly had to do with trigonometric measurements to make tell the robot the distance and angle to target based on knowledge of the target's size.  We used camera software from NI to teach the camera to distinguish the target based on its colors.  The only "visual" outputs that I've ever used were mostly commands for motor movements, so I have absolutely no knowledge of the picture output.

I am good at math, but in the programming field I am a novice.  My preferred programming language is Java, and I am still really uncomfortable with block diagrams. I was pretty much thrust into the LabView program and told to accomplish a task without any preliminary training in its basics.  So I have to apply all that I can remember about programming lines of code to this block diagram layout.

 

 

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.

The LabView version that I have is 8.5 1f5   I unfortunately cannot open the code that was posted because it is made in v 8.6

 

I did read the thread that was linked above, but I cannot open any of the code in that either.  This is the program I found that I CAN look at.

 

 

0 Kudos
Message 10 of 34
(13,836 Views)