Code for a pong game written in C++

Hi there
I have this computer graphics project, to implement a pong game written C++, using openGL. I have never done such a project before and I'm not keen to C++. Thus, if anyone have the code of a pong game written in C++, please don't hesitate to help me...
Thankx in advance

Why not create a DLL?  It doesn't have to be in C -- I was using one done in C# today and have also used DLL's written in C++.  If you can make it into a DLL, LabVIEW can call it (although there are certain details like pointers and structures that have to be taken care of.
If you want to use a CIN, keep in mind that just about everything you pass back will have to be done with a file....
-Matt Bradley
************ kudos always appreciated, but only when deserved **************************

Similar Messages

  • Where Can the Sample Code for That Balloon Game Demoed on WWDC for Swift Be Downloaded

    Hi. I can't find the balloon game sample code used in the WWDC in the Sample Code for iOS or OS X (assuming it's available for download). If it is available for download by Apple, where can it be downloaded?
    Thank you in advance.
    God bless, Cor. 13

    The assets are in the .playground file's file package. Select the .playground file in the Finder, right-click, and choose Show Package Contents to browse the file package. The graphics files are in the Resources folder inside the file package.

  • 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.

    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?
    LabVIEW Champion . Do more with less code and in less time .

  • Need code for 3d game or anything

    I need the code for a 3d game or anything because i want to study the code so I understand how to make something 3d.

    Here ya go:
    class myClass {
      myClass(){
      public void main(String[] args){
    }You fill in the blanks.

  • Lost extras for The Hunger Games: Catching Fire redemption code

    I redeemed the code for The Hunger Games: Catching Fire that came with my blu-ray. The movie downloaded fine, but the extras failed with an error, and after multiple retries and a reboot, the extras download has completely disappeared from my purchases. How do I recover it?

    Hello hunter7411,
    Thank you for choosing to purchase The Hunger Games: Catching Fire from Best Buy. Our ad from Mar. 2, 2014 to Mar. 8, 2014 does call out The Hunger Games: Catching Fire Blu-ray Exclusive Steelbook as including the Blu-ray, DVD and UltraViolet Digital Copy. We were recently informed that the DVD copy is not actually included, and I am truly sorry for any confusion this has created.
    To help assist our customers that were expecting to receive the DVD copy with this version, we have partnered with Lionsgate to offer a solution. Please contact Lionsgate by calling 1-877-230-2756 or emailing them at [email protected] They will ask to verify your purchase and then work to provide you with the DVD version.
    Thanks again for choosing Best Buy, and please let me know if you have any additional questions.
    Sincerely,
    Matt|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

  • Code i use to increase the difficulties on a flash pong game?

    i need code to apply on my flash game to make the pong game more difficult as the game goes on.
    help?

    lwood655 wrote:
    I changed the passcode needed to open my phone,  when I try to do a restore on this phone, it is asking for a passcode and not accepting the one I changed it to
    There are several different passcodes associated with any iOS device:
    The screen unlock passcode. This is normally a 4 digit code (although there is an option to make it longer).
    Your iCloud passcode. This controls Find my iPhone and Activation Lock, the theft deterrent measure that prevents a stolen or lost phone from being used. This will be prompted for if Find my iPhone is enabled when you restore the phone.
    Possibly the passcode to unlock an encrypted backup, as @Drew Reece pointed out.

  • What do i need for a classic pong game with real-life interface/ speedy-33?

    Lo guys, i'm a student, for my academic project i was kinda hoping to do a classic pong game with LabVIEW... 2 Palettes, a ball... except the goal is to involve the "outside world in this poject". So i was thinking of moving the palletes when a player's finger is moved (i guess i need a sensor, was thinking of placing a bright color on each finger so as to be detected). Note that i would be using speedy-33
    please guys i am very new to labview, and i need a project, i got one but i still dunno how to produce it... Thank you all
    Best regards.
    T. A.

    This should give you a good start. We did this as a wait window when we were updating software. It is old code so I do not want any comments on the coding style. It was done in fun and has not been updated in almost ten years.
    You will have to update the controls to work from a control vs automatically. Have fun let me know how this turns out.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Update Software.vi ‏10 KB
    PONG.vi ‏55 KB

  • Need code for the following chess game..plz help me out

    Hi,
    Problem:Move the chess piece "KNIGHT" from any location on a "3 x 3" Chess Board and make it go to the far right hand bottom corner.Chess Board in the problem is not the usual Chess Board of 8 x 8.KNIGHT starting position may be any position on board.Program should exit when knight moves to 3 x 3 corner.Here is how my Chess board looks.
    |.... |.... |.... |
    |.... |.... |.... |
    |.... |.... |Queen |<<--The Queen should reach this position
    Remember: KNIGHT moves in specific way such as 2 steps in one direction and 1 step left/right.If the KNIGHT starts are position (2,2) then it cannot move further and you have to throw exception with some error message.
    Run command: "java <some class> x y", where x is x-coordinate and y is y-coordinate(starting position of Knight) on the chess board. For this problem x & y could be 1(min) and 3(max) values and any value(2) in between.
    Deliver : 1) Send me the java code for above problem.
    2) Java code should compile and run.
    3) I will be interested in "Object Oriented Design" thaught process.
    4) Your coding style
    5) Javadoc
    6) Makefile
    I would be more interested in your class design, interface design and error handling.
    please mail the solution to [email protected]
    thanks n regards
    Chinu

    Hi, Here Knight moves like horse. Queen doesn't
    exist. If knight moves to (3,3). Game will be over.
    I am facing problem to move knight from one point
    to another point. And also i have some confussion on
    selecting interfaces and classes.<font size="10000">do your own homework</font>

  • Hello sir,i need labview code for a code which is written in matlab,latter one is attached with this message.

    hello sir,i need labview code for a code which is written in matlab...
    clc;
    close all;
    clear all;
    Ez= zeros(1,200);
    Hy=zeros(1,200);
    Ca=1;
    Cb=.4519;
    n=1;
    while(n<1500)
    for k = 2:200
    Ez(k)=Ez(k) + Cb*(Hy(k)-Hy(k-1));
    end
    Ez(1)=1;
    for k=1:199
    Hy(k)=Hy(k)+Cb*(Ez(k+1)-Ez(k));
    end
    plot(Ez,'b')
    hold on
    plot(Hy,'r')
    hold off
    pause(0.001);
    n=n+1;
    end
    thanku

    Well, this code is quite trivial and if you have to learn LabVIEW anyway, you might as well try to implement it.
    A few things to remember:
    The first array element in LabVIEW has index #0, while in matlab it has index #1, so everything dealing with array indices needs to be adjusted slightly.
    The zeroes function equivalent is "initialize array".
    Keep the array in a shift register as you update elements.
    use FOR loops.
    Use one of the graphs to display the data.
    LabVIEW Champion . Do more with less code and in less time .

  • HT201592 I redeemed my code for the first season of game of thrones for the digital copy but only 1 episode downloaded. why did this happen? what should i do?

    So I have a Samsung laptop with a terabyte of space, my itunes is up to date. i went online to redeem the code for my digital copy of the first season of game of thrones but when it downloaded, only 1 episode downloaded. why didn't the rest of my episodes download? how do i get them?

    Hello annefromnorth stonington,
    Thanks for the question. Let’s try checking for available downloads from your iTunes account:
    iTunes 11 for Windows: Check for iTunes Store purchases
    http://support.apple.com/kb/PH12505
    Make sure all your purchases have been downloaded
    Make sure you’re connected to the Internet.
    In iTunes, choose Store > Check for Available Downloads.
    Enter your Apple ID and password (if requested), and click Check.
    If there are no averrable downloads, check your purchase history for the missing episodes:
    See your purchase history in the iTunes Store - Apple Support
    http://support.apple.com/en-us/HT201271
    Cheers,
    Matt M.

  • Written code for transportation

    hi i have done transportation in sap bi/bw it sucessfully completed for se10 after that i have to see written code where i see that written code i think that se03 tcode what is the useful for se03 tcode and what's the purpose of written code kindly explain me briefly about written code and transportation also.

    Hello,
    Transportation is moving created objects with the landscape that is create the objects in Dev and collect it in the Request which can be move across the landsacpe.
    Return codes are nothing but the status of the transport request which is moved to target. It can endup with warnings ( Return code = 4) or successful ( return code = 0) or errors ( return code = 8). It is to identify whether the changes has been moved to the target system successfully or not.
    SE03 is the transport organizeris the tool to display request type and request status.
    Thanks.

  • How to embed html codes for videos games etc... in action script 3.0

    i am trying to embed a chatbox on my action script 3.0 website. but i am having no succes. any help on how to get my chatbox on a page using html code

    Hey thnx Ned.
    this sites are really helpful.but,i have used sound through button.so how it is possible to attavh the link with slider.i have created slider also.
    Below is my slider code for sound.
    onClipEvent (load) {
        mySound1 = new Sound();
        mySound1.loadSound((myScale)+"/"+(myTanpura)+"/"+(myTanpuraSwar)+"/"+(myTanpuraTempo)+".w av", true);
        mySound1.onSoundComplete = function() {
        mySound1.start();
        mySound1.start(0.058,999);
    onClipEvent (enterFrame) {
        downloaded = mySound1.getBytesLoaded();
        total = mySound1.getBytesTotal();
        if (downloaded != total) {
            _root.dl = "You have to buy this software...";
        } else {
            complete = 1;
            _root.dl = "";
        mySound1.setVolume(ratio * 2);
    This code is working for slider.I mean it scrolls the slider.but it dosent make any effect to sound.
    Below is my button code.
    stop();
    mySoundBtn4.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.attachSound("mySoundClip4");
              mySoundC.start(0, 300);  //10 represents the number of loops
              gotoAndPlay("play1");
    this is on button's frame.not exactly on button.
    Button and Slider both are on diffrent scene.
    Can you plese help me out?

  • Unable to enter code for a game in C3

    I have downloaded a Midnight Pool 2 demo from the Nokia Ovi Store through my mobile, purchased code for P50 from Smart, my provider, it will not allow me to enter code in the code box is it that I'm using qwerty keys, no matter what I press it will not enter any characters. Please advice thanks
    I have emailed gameloft support and got no reply.

    Hello,
    If  the code you need to enter are numbers, you need to press the "function" key first (in the bottom left corner of the keyboard).
    Hope this helps.
    Regards.
    C3-00 V 08.63 25-03-11 RM-614 Variant: 00.00

  • Pong Game Problem

    I have a problem with my pong game. IT says its missing a return statement at :71: and at someplace else. How do I fix this? Below is the source code. Note that I haven't done puck-paddle collisions yet. It isn't supposed to do those right now anyway, so please try to fix the return statement problem, not that. Here is the code:
    import java.applet.*;
    import java.awt.*;
    public class Ponggame extends Applet implements Runnable
         int score = 0;
         int otherscore = 0;
         int y_speed = 0;
         int other_y_speed = 0;
         int appletsize_x = 640;
         int appletsize_y = 480;     
         int xpos = 620;
         int ypos = 220;
         int otherxpos = 20;
         int otherypos = 220;
         int ball_xpos = 130;
         int ball_ypos = 130;
         int radius = 20;
         int ball_xspeed = 2;
         int ball_yspeed = 2;
         int paddle_width = 32;
         int paddle_height = 80;
         int other_paddle_width = 32;
         int other_paddle_height = 32;
         //Variables for Double Buffering
         private Image dbImage;
         private Graphics dbg;
         public void init()
              setBackground (Color.black);
         public void start()
              Thread th = new Thread (this);
              th.start ();
         public void stop()
         public void destroy()
         public boolean keyDown (Event e, int key)
              if (key == Event.UP)
                   y_speed = -2;
              else if (key == Event.DOWN)
                   y_speed = 2;
              else if (key == 119)
                   other_y_speed = -2;
              else if (key == 115)
                   other_y_speed = 2;
         public boolean keyUp (Event e, int key)
              if (key == Event.UP)
                   y_speed = 0;
              else if (key == Event.DOWN)
                   y_speed = 0;
              if (key == 119)
                   other_y_speed = 0;
              else if (key == 115)
                   other_y_speed = 0;
         public void run()
              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
              while (true)
                   if (ball_xpos > appletsize_x - radius)
                        otherscore += 1;
                        ball_xpos = 120;
                        ball_ypos = 120;
                   else if (ball_xpos < radius)
                        score += 1;
                        ball_xpos = 120;
                        ball_ypos = 120;     
                   else if (ball_ypos > appletsize_y - radius)
                        y_speed = -2;
                   else if (ball_ypos < radius)
                        ball_yspeed = +2;
                   else if (ypos<0)
                        ypos = 0;
                   else if (ypos+paddle_height>appletsize_y)
                        ypos = (appletsize_y - paddle_height);
                   else if (otherypos<0)
                        otherypos=0;
                   else if (otherypos+other_paddle_height>appletsize_y)
                        otherypos = (appletsize_y - other_paddle_height);
                   ypos += y_speed;
                   otherypos += other_y_speed;
                   ball_xpos += ball_xspeed;
                   ball_ypos += ball_yspeed;
                   // Neuzeichnen des Applets
                   repaint();
                   Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
         public void update (Graphics g)
              if (dbImage == null)
                   dbImage = createImage (this.getSize().width, this.getSize().height);
                   dbg = dbImage.getGraphics ();
              dbg.setColor (getBackground ());
              dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
              dbg.setColor (getForeground());
              paint (dbg);
              g.drawImage (dbImage, 0, 0, this);
         public void paint (Graphics g)
              g.setColor (Color.red);
              g.fillOval (ball_xpos - radius, ball_ypos - radius, 2 * radius, 2 * radius);
              g.setColor (Color.white);
              g.fillRect (xpos, ypos, paddle_width, paddle_height);
              g.fillRect (otherxpos, otherypos, other_paddle_width, other_paddle_height);
    }

    Your public boolean keyXXX methods don't return a boolean.
    And use code tags when posting code. There is a code button above the message editor.

  • KeyListener for a simple game?

    I am begining to write a simple game, and I can't get the keyListener to work. I had written a pong game on jdk 1.3.1 and it worked fine. I used public boolean keyDown(Event e,int key){. I have been looking all over and can't find a keyListener that works on 1.4.1. Any help would be appreciated. So far I have:
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class Game extends Applet implements KeyListener,Runnable {
         Toolkit toolkit = Toolkit.getDefaultToolkit();
         static Image picture;
         Graphics offscreen,g;
         Image image;
         int x=1,y=10;
         static final int REFRESH_RATE = 200;
         Thread animation;
         public void update(Graphics g) {
              paint(g);
         public void init(){
              image=createImage(500,300);
              offscreen = image.getGraphics();
              picture = toolkit.getImage("Neo1.gif");
         public void start(){
              animation = new Thread(this);
              if(animation!=null){
                   animation.start();
         public void paint(Graphics g){
              offscreen.drawImage(picture,75+y,60,32,46,this);
              g.drawImage(image,0,0,this);
         public void keyTyped(KeyEvent e){
            //Anything I put here does not work???
         public void keyPressed(KeyEvent e){
         public void keyReleased(KeyEvent e){
         public void run(){
              while(true){
                   repaint();
                   try{
                        Thread.sleep (REFRESH_RATE);
                   } catch(Exception exc) { };
         public void stop(){
              if(animation!=null){
                   animation.stop();
                   animation=null;
    } [code/]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Heres my actual code that does work:
      class PlayingPanel extends JPanel implements KeyListener {
        public PlayingPanel() {
          this.setBackground(Color.black);
          this.grabFocus();
        public void paintComponent(Graphics g) {
          super.paintComponent(g);
          g.setColor(Color.black);
          g.drawRect(0, 0, this.getWidth(), this.getHeight());
          g.setColor(Color.white);
          g.drawString("Right: " + keys[0], 10, 15);
          g.drawString("Up: " +    keys[1], 10, 30);
          g.drawString("Left: " +  keys[2], 10, 45);
          g.drawString("Down: " +  keys[3], 10, 60);
          g.drawString("Released: " +  keys[4], 10, 75);
          g.drawString("Typed: " +  keys[5], 10, 90);
          g.drawString("Pressed: " +  keys[6], 10, 105);
        public boolean isFocusTraversable() {
          return true;
        public void keyReleased(KeyEvent e) {
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            keys[0] = false;
          } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            keys[2] = false;
          if (e.getKeyCode() == KeyEvent.VK_UP) {
            keys[1] = false;
          } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
            keys[3] = false;
          keys[4] = true;
        public void keyPressed(KeyEvent e) {
          keys[6] = true;
        public void keyTyped(KeyEvent e) {
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            keys[0] = true;
          } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            keys[2] = true;
          if (e.getKeyCode() == KeyEvent.VK_UP) {
            keys[1] = true;
          } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
            keys[3] = true;
          keys[5] = true;
      }Hope this helps.
    CoW

Maybe you are looking for

  • How can I change the iPhone backup location on my Mac to an external hard disk?

    Thank you.

  • Users found, but not displayed in console with WL8.1 SP5 and iPlanet LDAP

    Hi all, I've just installed WL8.1 SP5 and have recreated my domain configuration, as happily used by SP4. All seems well until I add an iPlanetAuthenticator via the console. The console reports that it has been created successfully, but when I browse

  • Problem in finding image resources upon deployment

    hi. im put used some images in my buttons and everything works smoothly if i run it through netbeans. however, once i try to run the application independently (running the jar file in the dist folder) the image resources cant be found. could anyone p

  • My iphone 4 is block

    Good afternoon, I'm French. Ok here is my problem. My iphone 4 is block, and he was power on not long before he block. I sent a sms and locked the iphone, 5 minutes after, i want to check if i had a reply, and, i cannot do anything, the screen is pit

  • Skype Number Not Forwarding

    My MX local skype number is active, current on billing and the forward is setup to a US (Dallas, TX) landline.  The forward is not working properly and going to a message saying the number is inactive.  The direct US landline number is working proper