robots. This will be a graded lab which you'll work on
in groups of two. (You may work on your own if you
ask for approval in advance.) First, carefully plan out your program.
Before doing any programming, you should get your plan endorsed.
robots predates the ubiquitousness of
graphical interfaces, so you have to play using keyboard input.
M-x man (for manual-page), and
enter -M ~mc38/man robots. This gives your directions on
how to play. (The -M ~mc38/man part says ``Please look
for the man page in the MC38 directory.'')
~mc38/bin/robots.
Just as Horstmann plans out the Clock game in chapter 8, you should plan out your program. You should have at least two classes (probably more), and should plan on most of your code being in member functions (as opposed to non-member functions).
Decide in advance what order you will write your classes and functions. You don't need to program a whole class all at once. On the contrary, I recommend coding part of it, testing a bit, and continuing. Plan how you will test as you go along.
robots
program more.
README which has the following:
robots game.
The program
~mc38/labs/robots/random_points.cc
reads characters from the keyboard, and places those characters on
random points in cwin. It demontrates how to address the
first few problems below.
See
~mc38/labs/robots/random_points.cc
In particular, you need the system ("stty raw"); to let
the computer know you want to read a character as soon as it's typed,
and not wait for the "return" or "enter" key to be hit.
Stuff isn't drawn until
either (1) you do something like a cwin.get_point() or
(2) you return from main() or (3) there are many things
that need to be drawn (filling a buffer). If you include a loop which
draws 50 points off the screen, the window will be forced to redraw.
for (int i = 0; i < 50; i++)
cwin << Point (-15,-15);
Maybe you forgot to include a library like -lX11. Check
the compilation command your Makefile uses with care.
ccc_win.cpp more than once. Be
sure this is only included at the top of
main(). Elsewhere, include ccc_win.h
instead.
#include a .cc file. Only
#include .h files. (Except,
#include ccc_win.cpp at the top of main.cc)
vector of
objects?
Perhaps you don't have a default constructor for that class, i.e., one which takes no arguments.
Check the end of an included .h file. Perhaps you left a
; off the end of a class declaration?
In short, you can't. The graphics classes are limited for pedagogical reasons. The book describes all graphics classes in the appendix.