Thread: Need help understanding the C code for the game Paratrooper.

  1. #1
    Registered User
    Join Date
    Oct 2015
    Posts
    1

    Need help understanding the C code for the game Paratrooper.

    Code:
    /* x coordinates of paratroopers at the point of jumping from helicopters */ 
    int jump_pt[8][4] = {                        53, 235, 405, 587,
                            600, 574, 66, 40,
                            79, 196, 444, 561,
                            548, 522, 118, 92,
                            105, 209, 431, 535,
                            496, 470, 170, 144,
                            131, 222, 418, 509,
                            483, 457, 183, 157
                         } ;
    Could someone explain how exactly these coordinates are decided? Are they just random numbers? This code is from the book C Projects by Kanetkar. I'm trying to implement it as part of my project in college. Any help would be appreciated.
    Last edited by Salem; 10-22-2015 at 03:14 AM. Reason: line wrapped

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Your guess is better than mine: I have never heard of the game called Paratrooper, and even if I had, my name is not Kanetkar.
    Last edited by laserlight; 10-22-2015 at 02:04 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    There are bajillions of Paratrooper clones. I remember playing this one (Youtube video). Per the comment, the values are the x coordinates where the helicopters drop a paratrooper.

    Are the values random? Why don't you use your tools to check?

    I saved the values to a file, one number per line, adding the line number as the second number on each line, and told my trusty gnuplot to
    Code:
    gnuplot -pe 'set xrange [0:640]; set yrange [0:33]; unset ytics; plot "file" u 1:2 notitle w lines, "" u 1:2 notitle w points lc -1'
    and it drew this plot for me:
    Need help understanding the C code for the game Paratrooper.-paratrooper-png
    I'm sure you could use LibreOffice Calc, Excel, or any number of other tools to draw it if you don't want to use gnuplot.

    Note that the vertical axis is not relevant, I just didn't want the lines to overlap, and stretched it upwards. That's why I used the line number. The first value is at the bottom, the last value at the top. If you want it reversed, use u 1:(-$2) instead of u 1:2 for gnuplot, to negate the vertical axis.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding this code
    By sameertelkar in forum C Programming
    Replies: 11
    Last Post: 01-04-2013, 07:36 AM
  2. Help understanding a Code
    By shiroaisu in forum C++ Programming
    Replies: 3
    Last Post: 05-25-2010, 10:05 AM
  3. I need help understanding this code
    By Sshakey6791 in forum C++ Programming
    Replies: 5
    Last Post: 12-23-2008, 02:49 PM
  4. Replies: 8
    Last Post: 09-09-2005, 12:34 AM
  5. Code Understanding!
    By Jill n Jall in forum C++ Programming
    Replies: 1
    Last Post: 01-16-2003, 04:16 PM

Tags for this Thread