Space Invaders in C

Miscellaneous Forums/General Discussion/Space Invaders in C

Anyone had any success with this ? Or know of any good links.... I'm developing my 'C' skills and am interested in doing a game in C of this ilk.

I came across some letter invader stuff, did battle with getting it to compile within my VMWare install of Linux - successfully installed an ancient LTERMCAP library, got an exe only to discover some BIN file couldn't be opened.

Yes, I do much prefer Blitz but sometimes you cannot pick your tools.

Regards, BP.

My suggestion is to go to your local bookstory/libery - I'm looking at a book for C++ game programing:

Sams Teach yourself Game Programming in 24 hours


or somthing like that, its C++ i think, i'ma look at it, (i'm learning C++ :D)

Try getting hold of the Allegro library for writing games.

TBH the last time I did space invaders in C was when CGA was still around. I would really look on the net for some really good tutorials on how to do it.

I wote ASCIIVADERS in C - no long have the source though

I wrote most of an invaders game in C++ and SDL... the code wasnt really something Im particularly proud of and I did plan to re-write it properly having learnt what was required to write it.
Then I lost interest and went back to Blitz.
Not even sure where I filed the code away to now I think about it.

Sams Teach yourself Game Programming in 24 hours
Hey I've got that! Oh no, wait it's in 21 days (and it's for DOS) :-)

Thanks folks, will try doing a search on C tutorials + games,

regards: BP.


Teach yourself Game Programming in 24 hours



Good book that one, I've read it... Though its specific to windows as it uses GDI to do the drawing!

Not a bad thing, as the 2D sample games run at a tidy framerate.

Recommended

Dabz

Are we talking C++ as well or strictly C? For C++, get Allegro and the Bloodshed Dev-CPP package then just Google your way to knowledge.

SpaceAce

Thanks, have used the bloodshed compiler many moons ago when delving into C++, before I realised it was C I needed. Have since used Visual Studio, Code Warrior 6 and at the moment I'm command line compiling in Linux.

Unfortunately my C orientation is Linux esque, not windows.

i think Dev-C++ does normal C as well, you should look up some books, lots of great ones out there..

This sites explains pointers VERY well....

http://www.cprogramming.com/tutorial/c/lesson6.html

Incidentally, tried using my copy of Visual Studio to compile some C, it creaked and groaned for about 10 mins, gave up , resorted to code warrior 6 on my wifes laptop - yay code warrior 6, VStudio 2005 - not say yay. S'pose VStudio is a bit of a sledge hammer to crack a nut. (A SLow sledge hammer at that....)


i think Dev-C++ does normal C as well,



ANSI/ISO C (Or standard C) is recommended to be supported by every compiler.

In Visual Studio 2005 (I have Express), when creating a new solution, make sure when adding a new source file that it has an extension of .c not .cpp

Works for me using Standard C, unless your are doing something, erm, thats not standard (e.g platform specific)! ;)

Dabz

main I had to learn about pointers when I was about 12 in order to code assembly. It was called Indirect Addressing in those days and was a bit tricky to get your head round, but OK once you did :)

@Dabz, thanks, I'd decided to just do a bit of C in Windows for the time being (my Linux is in VMWare...), tried my copy of VS 05 but didn't even get as far as changing the default new source file from .cpp to .c, it had problems opening up.

@grey, I'm impressed, when I was 12 I got as far as basic on the Speccy - looked quickly at assembler but quickly lost interest. made up for it later though, a few years back managed to program my first PIC with assembly, pulses in the order of microsecs. The goal was to develop a transponder system - hasn't happened yet!

Yeah I learnt assembly on the C64 first then also Spectrum and BBC, but I did the most on the Amiga a few years later. Was a bit long winded thought to make anything happen so when Blitz Basic 2 came out I loved it's ease and speed.

#!/usr/bin/perl

                        use strict;
                use Term'ReadKey;ReadMode
          'cbreak';$,=$/;$/=++$b+$b;$=='8';$b=$=
    x28;$*=$=x2;@!=(qw(4 _ " a 1 1 0 0 ));$![7]=`clear`
;push(@!,split shift(@!),q 7$=W8W$=8$b eq "j"8W$=8$=W8 $b eq
"l"8W$=8W!8($b eq"k"&&$_!~/!/)a#W$=8#$=W8$=W#8W$=#8#!8##a\*8
$=8p$=8$=p        8$=q8q$=8p(#.{59})$=8$=$        1q8#q(.{60
})$=8#$=$1        pap(.{60})!8$![0]++;"\*$        1$="8q(.{6
0})!8$![0]        ++;"\*$1$="8(t.*)!8$b=(l        ength$1)-6
1;substr($        1,0,$b )."!". substr($1,        $b+1).$=4x
"gs'"x"c"es'"c"z"gs if'.shift"z"l"just another perl hacker"l
4'SpaceInvaders'.($=x12).'domm@... j=left k=fire l=right'
_'#'x58_("$*p$*"x11).$=x3_$*.("$*$*q"x11).$=_("p$*$*"x11).$=
x3_($=x3).("$*$*q"x11)_1_$b.$=."W$b"_'#'x 587);j(split shift
@!,pop@!);a(split shift@!,pop@!);push(@!,split shift@!,pop@!
);$_=$a;map{s/\n//g}@!;map{s/v//g}@!;map{s/  //g}@!;&p;sub'j
{$_=shift;$a.=m/^1/?("#$b$=$=$b#$,"x12):"#".eval( )."#$,";@_
&&j(@_)}sub'END{ReadMode 'normal' }sub'a{eval"sub'".pop().'{
eval\'s/\'.(shift).\'/\'.(shift).\'/'.pop().';@...().'(
@_)}';@_&&a(@_)}sub'p{$b=ReadKey -1;$![1]%3==0&&x(split$=,$!
[6]);z(split$=,$![4]);x(split$=,$![5]);c(split$=,$![7]);$![1
]++;select+(@-,@-,@.../$=/ /g;/pW|Wq/&&h('
Game over');$_!~/p|q/&&h('You saved our planet. Yeah');print
$![3],$![2          ];&p}sub h{print $![          3],shift,"
You killed          $![0] space invaders          ",$,;exit}



(edit) Oops, that's Perl. (/edit)

I was kinda hoping for:


int main  {             int alien=1;              int ufo=1;
int play=1;             int play =2;              int play=3;
int life=3;             int score=0;              int hi_s=0;


     printf("shield1\n");         printf("shield2\n");
     printf("shield3\n");         printf("shield4\n");



                           /*/
                          /**/



                          /**/
                        /******/
                        /******/
                        return 0;

}



How do I make it move ?

Got my invaders going left and right and descending, got logic in for bullets (both enemy (with potentially a 'homing' aspect to it!) and player) ... and am even considering multiplayer.

Oh, wrote my first file to my C: drive via my Space Invaders executable... written in 'C'. Deep Joy (;-)

Just figured I'd chime in with a little bit of information. Bloodshed Dev-C++ is not a compiler, it is only an IDE. Many people tend to get confused and believe this is more than that, but it isn't. The compiler is MinGW, a port of the GCC tools/compilers to Windows.

I'm not sure why people always confuse the two, but it's worth knowing, and knowing is half the battle!

Cheers Noel, it is interesting to know that gcc has been ported (thru MinGW) to windows - in bloodshed's incarnation, interestingly (if you do unix/linux) it's only via a ported version of gcc that I've ever compiled any C++.

Space Invaders in C/C++ .... accomplished (;-)

Thanks to Brucey for some tips on C++. Exe is 480Kbytes....