Newsgroups: comp.os.msdos.djgpp From: Elliott Oti Subject: Re: Teaching a child to program in C Sender: usenet AT phys DOT uu DOT nl (News system Tijgertje) Message-ID: In-Reply-To: <35F56D01.4BC6@erols.com> Date: Tue, 8 Sep 1998 20:09:34 GMT Content-Type: TEXT/PLAIN; charset=US-ASCII References: <35F56D01 DOT 4BC6 AT erols DOT com> Mime-Version: 1.0 Organization: Physics and Astronomy, University of Utrecht, The Netherlands Lines: 50 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Tue, 8 Sep 1998, John S. Fine wrote: > Can anyone give me any ideas for programming projects > that would be simple enough for a 7 year old to follow, > but interesting enough for a 7 year old to care about? > > I expect that graphics would be a good way to make it > interesting. I have never done any graphics in DJGPP > (only in real mode assembler). He might want to try programming something simple using Allegro. http://www.talula.demon.co.uk/allegro Once he has the ability to write a simple "hello world" type program he can try making simple animations with Allegro. A typical program would go like this: 1. Initialize Allegro with allegro_init(); 2. Set the video mode with set_gfx_mode() -- you might want to see which modes are the most stable on your computer. 3. Draw a simple circle/triangle/rectangle/line/ellipse on the screen with the basic functions triangle() circle() rect() etc. In literally 3 or 4 lines of code he can have the graphics mode set and a graphics primitive of his choice sitting on the screen. If he's bright enough you can introduce him to things like getting the (say) circle to move around on the screen, getting it to change colour, getting it to do things in response to keypresses (ie if 'r' is pressed change the colour to red, if 'g' is pressed change the colour to green, etc, that sort of thing). All this can be done in 10 lines of code or less in one single main() function using Allegro, with simple, non-complicated functions, and the simplest of C constructs. If he enjoys that he can go on to write simple programs that will display PCX,BMP,TGA etc pictures on the screen (can be done in 4 or 5 lines of code), play MIDI music files, play FLI animations, mix sound effects and pictures (record a WAV file of your son saying "Whoops!", then let him write a simple program whereby a circle changes colour and says "Whoops!" while doing so). And so on, and so forth -- I'm sure creativity will prevail. Cheers, Elliott Oti http://www.fys.ruu.nl/~oti "Q: What did the elephant say to the naked man? A: It's cute but can you pick up peanuts with it?"