LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Classic Pong

Solved!
Go to solution

You code make little sense.

 

  • Why do you use a filtering event (key down?) instead of a plain event (key down) ?
  • That "built array" on the left make no sense at all. It has no useful function. Delete it!
  • Don't use a shift register in the outer loop, because you need to draw a new paddle each iteration.
  • You need to start with a full 20x30 2D boolean array. Right now you only have a 2D array with a single column.
  • 200ms is probably too slow.
  • Your inner FOR is not needed, because "replace array subset" can replace entire arrays. (If you use a FOR loop, you would need a shift register for the array).
  • You need to move the insert point based on the key states.
  • ...
Message 11 of 22
(5,064 Views)

ok I changed a couple of things but I am still a little confused about the replace array subset I get how the for loop is not needed, but I just dont know what to put in the replace element?

 

thanks

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 12 of 22
(5,059 Views)
here is my code:
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 13 of 22
(5,057 Views)

No! You now have an empty boolean array in a shift regsiter, so replacing elements will not work. You can only replace existing elements. The array in the shift register must be the size of the playing field.

 

Here's a quick modification of my old VI adding the paddles. It also shows a way to read the up/down buttons.

 

(I also changed to classic booleans for efficiency). The computer plays perfect, so you cannot win. 😄

 

See if it makes sense to you. 😉

 

 

Message 14 of 22
(5,035 Views)

I understand what you did I just wish I could have thought of it lol. 

 

 

wow impressive

 

thanks man you know your stuff

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 15 of 22
(5,018 Views)
yeah you def. can not win lol
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 16 of 22
(5,013 Views)

hey guys/gals

 

well I have been working on this for about an hour and I figured I could make it a little bit more random so that you can win lol

 

so my attempt failed maybe someone can tell me why.

 

thanks

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 17 of 22
(4,988 Views)
Solution
Accepted by topic author Harold_Timmis

I would just accumulate a small random error, e.g. as follows.

 

I also made a small change to make the paddle more responsive (eliminating the key repeat and coding around it to remove the key repeat delay).

Message 18 of 22
(4,966 Views)

well I geuss that is why your a labview champion thank you for the help with this like I said before I only wish I would have thought of it.

 

Thank You,

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 19 of 22
(4,961 Views)
Well, this was just a very quick and rough draft, it would need quite a bit more work. For example you might want to add small changes in vertical speed depending of the vertical impact point on the paddle and the paddle speed at the time of impact, for example.  😉
Message 20 of 22
(4,953 Views)