Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Skyline (Missile Defense Remake) -OR- My First Game!

This thread is locked; no one can reply to it. rss feed Print
Skyline (Missile Defense Remake) -OR- My First Game!
Edgar Reynaldo
Member #8,592
May 2007
avatar

I always liked to play the Missile Defense game where you defended a city from incoming missiles with missiles of your own. And that was ages ago when I was learning GWBASIC. :D

Presenting my version, completed in a coding marathon in just over 22 hours, Skyline!

AKA, My first gameTM!

{"name":"605037","src":"http:\/\/static.allegro.cc\/image\/cache\/2\/4\/24527a09650b07e2211aa071b3477751.png","w":812,"h":632,"tn":"http:\/\/static.allegro.cc\/image\/cache\/2\/4\/24527a09650b07e2211aa071b3477751"}605037
{"name":"605038","src":"http:\/\/static.allegro.cc\/image\/cache\/8\/b\/8bee644a4ca5b90044579d56ee137a3d.png","w":812,"h":632,"tn":"http:\/\/static.allegro.cc\/image\/cache\/8\/b\/8bee644a4ca5b90044579d56ee137a3d"}605038
{"name":"605039","src":"http:\/\/static.allegro.cc\/image\/cache\/e\/e\/ee35967486ff037c964c92724c5bbb2b.png","w":812,"h":632,"tn":"http:\/\/static.allegro.cc\/image\/cache\/e\/e\/ee35967486ff037c964c92724c5bbb2b"}605039

Skyline.7z (Binary + DLL's + Resources)
SkylineSRC.zip (Source {depends on my Eagle lib})
(Extract to a new folder)

Get 7-zip here if you need it...

I can't get png's or jpg's to load magic pink properly and I don't know why... They don't masked_blit properly but show up as hot pink instead of transparent like they should be. Ideas?

Also, I'm genuinely interested in constructive criticism about my source code - structure / best practices / whatever, as detailed as you would like to be.

Edit
Forgot to mention, the game is fully configurable through Data/Config.txt and Data/Cities.txt. The easy/medium/hard settings definitely need to be tweaked for better gameplay, but I don't have time today.

The first city listed in Data/Cities.txt is the one that will be loaded - haven't finished a proper menu screen yet. :P

Edit2
Update! New screenshots! Better colors! ++GradientCircles()!

SkylineEXE.7z (updated exe)
(extract over the folder where you extracted Skyline.7z)

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

GullRaDriel
Member #3,861
September 2003
avatar

Pack with dlls working fine in W7 x64

I can't see if there is any musics or sounds (I'm @ work)

Only 3 bullet at a time (sic, I was wanting an aracade mode with high speed bullets and xplosions !!) and I don't really understand why the cursor is changing colors.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!
My FlickR ! - Old photo gallery
If no moderator answers you then register and PM here !

gnolam
Member #2,030
March 2002
avatar

I can't get png's or jpg's to load magic pink properly and I don't know why...

JPGs and magic pink — in other words, lossy compression and a single transparency color — don't mix.
As for PNGs, there's probably a color conversion issue. There's no reason to use magic pink with them, since they come with their own alpha.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

torhu
Member #2,727
September 2002
avatar

When I converted my game from A4 to A5, the magic pink wouldn't work. Turned out that the color I had used wasn't exactly #FF00FF. I suppose A4 had some level of tolerance that A5 doesn't.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Gnolam said:

As for PNGs, there's probably a color conversion issue. There's no reason to use magic pink with them, since they come with their own alpha.

I don't want to use translucent blending with A4 - no hwaccel. :-/

Gullradriel said:

I can't see if there is any musics or sounds (I'm @ work)

Not yet, but I'll see if I can find some good effects and/or music.

Gullradriel said:

Only 3 bullet at a time (sic, I was wanting an aracade mode with high speed bullets and xplosions !!) and I don't really understand why the cursor is changing colors.

Try using this config.txt file in the Data folder instead of the one that came with it and try the hard difficulty level.

Like I said, config.txt lets you change every aspect of the game.

The cursor is red when you can't fire yet, and green when you can.

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

GullRaDriel
Member #3,861
September 2003
avatar

The cursor is red when you can't fire yet, and green when you can.

Which explain why it was always red. I was clicking like a dumb !

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!
My FlickR ! - Old photo gallery
If no moderator answers you then register and PM here !

gnolam
Member #2,030
March 2002
avatar

I don't want to use translucent blending with A4 - no hwaccel. :-/

IIRC, you don't have to (with the right color conversion mode).

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Edgar Reynaldo
Member #8,592
May 2007
avatar

Gnolam said:

IIRC, you don't have to (with the right color conversion mode).

Well, this
set_color_conversion(COLORCONV_TOTAL | COLORCONV_KEEP_TRANS);
doesn't work.
I don't think load_png respects the color conversion...
In the png, the transparent background is 0,0,0,0 RGBA. If I save the png as a bmp after it is loaded using save_bitmap, then the transparent background is just black, not magic pink like it should be.

So for now I'm back to using bitmaps. :-/

Gullradriel said:

Which explain why it was always red. I was clicking like a dumb !

;D

Try the new config file I posted, or edit the values for player_tbl_easy / player_tbl_medium / player_tbl_hard in Data/Config.txt. Set them to the amount of time between launches. (0.010 should let you click as fast as you want!)

To make your missiles fly faster, edit the values for player_mspd_* (in pixels per second).

The config file has comments telling what each section does, and the naming should be fairly apparent - player / enemy.

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

kenmasters1976
Member #8,794
July 2007

I never liked the Missile Defense kind of games but congratulations on finishing a game!.

GullRaDriel
Member #3,861
September 2003
avatar

I tried and it's far better ^^

OASN, the explosion are all white here, and the snow particles explosions are a little bit too long to end.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!
My FlickR ! - Old photo gallery
If no moderator answers you then register and PM here !

Matthew Leverton
Supreme Loser
January 1999
avatar

(Source {depends on my Eagle lib})

Is that lib available? I'd run the game, but I'm rarely ever in Windows.

I'd comment on the code, but C++ makes me sick and I'm trying to forget Allegro 4 in order to save space for more important things. :-/

Edgar Reynaldo
Member #8,592
May 2007
avatar

Is that lib available?

Working on it. I haven't got the hang of writing a make file yet. My rules don't work the way I want them to yet. The code is up on sourceforge now though :

svn checkout http://svn.code.sf.net/p/eaglegui/code/trunk eaglegui-code

How do I write a rule that makes a target for every .o in a symbol depend on it's corresponding .c file?

This doesn't work :

$(COBJS) : $(CSRCS)
  @echo $(COBJS)
  @echo on
  @echo $(GCC) $(CFLAGS) -o $@ $<

It prints out :

c:\ctwoplus\progcode\allegro\Eagle>mingw32-make
testbuild/key_handler.o testbuild/timer_handler.o
g++  -o testbuild/key_handler.o src/key_handler.c

So there are two objects to be made, but only one is being made. ???

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

AMCerasoli
Member #11,955
May 2010
avatar

I think there is a typo... Wasn't in 22 hours, but 22 minutes... Sorry man, I thought you was able to come up with something much better than that :( . I mean, your collision detection test is 3 times better than this, and it's not a game... :-/

The explosions (big spots) are always white here... And how I change the city background?. And the bullets are just white pixels, not like in your images. Have you used Photoshop Edgar? ;D

In pro of originality my boss asked me if I could create an original register form, and I answered "yes, of course". One of the main features it had was the ability to be really original with all your user fields, no repeated phone number, no repeated address, email, username, etc... The problem was when I added the same to the password, and I notified the user that the password he was introducing was already taken, and who was using it, some minutes after I was fired...

Edgar Reynaldo
Member #8,592
May 2007
avatar

your collision detection test is 3 times better than this, and it's not a game...

What's wrong with the collision detection?

AMCerasoli said:

The explosions (big spots) are always white here...

That's because you didn't download the updated executable...

AMCerasoli said:

And how I change the city background?.

You can't change it through the game yet, because I haven't finished the menu yet. You can change it using Data/Cities.txt though, just change the first line to :

City name,Images/CityImage.bmp

Quote:

Have you used Photoshop Edgar? ;D

Isn't that what everyone does with their screenshots? 8-)

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

AMCerasoli
Member #11,955
May 2010
avatar

What's wrong with the collision detection?

The collision detection is fine, I'm just saying that I remember that you sent an example or a test of some kind of collision detection with some physics too (gravity) to someone and I keep it opened longer than this game... There was a big ball bouncing or something like that. :)

Quote:

That's because you didn't download the updated executable...

Ohh, I missed that, now looks much better.

Quote:

You can't change it through the game yet, because I haven't finished the menu yet. You can change it using Data/Cities.txt though, just change the first line to :

Oh I see.

It's fine man, keep improving it until you use 3D meshes and upload it to the Xbox Live and add a multiplayer section, with 32 players 16 being the attackers and 16 being the city protectors, and create nuclear booms that could explode the entire city in just minutes, and... and... Well... That's it.

In pro of originality my boss asked me if I could create an original register form, and I answered "yes, of course". One of the main features it had was the ability to be really original with all your user fields, no repeated phone number, no repeated address, email, username, etc... The problem was when I added the same to the password, and I notified the user that the password he was introducing was already taken, and who was using it, some minutes after I was fired...

altalena
Member #13,639
October 2011
avatar

Cool game! Thanks for the help with my allegro 5 mouse problem.

...At the briefest instant following creation all the matter of the universe was concentrated in a very small place, no larger than a grain of mustard. The matter at this time was very thin, so intangible, that it did not have real substance. It did have, however, a potential to gain substance and form and to become tangible matter. From the initial concentration of this intangible substance in its minute location, the substance expanded, expanding the universe as it did so. As the expansion progressed, a change in the substance occurred. This initially thin noncorporeal substance took on the tangible aspects of matter as we know it. From this initial act of creation, from this ethereally thin pseudosubstance, everything that has existed, or will ever exist, was, is, and will be formed. - the RaMBaN, 1194 - 1270

ג וּשְׁאַבְתֶּם-מַיִם, בְּשָׂשׂוֹן, מִמַּעַיְנֵי, הַיְשׁוּעָה. - Yeshayahu 12:3

Edgar Reynaldo
Member #8,592
May 2007
avatar

altalena said:

Cool game! Thanks for the help with my allegro 5 mouse problem.

Thanks! No problem.

Okay, so, I've got the Windows build of my Eagle library working pretty well, so now for the *NIX build.

First off, what's with *.so files? Why are there more than one for the same library? Is one the archive to link to, and the other the shared library to be loaded at runtime?

I'm trying to figure out what I should be creating for my library, but there are so many different .so files I don't know what to do.

Is this right?

gcc -shared -Wl,-soname,libmylibrary.so.1 -o libmylibrary.so $(OBJS)

What does that even do? Which one do you link to, and which one is the equivalent of the Window's 'dll'?

And what's with the numbering scheme? Are those supposed to be version numbers?

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

weapon_S
Member #7,859
October 2006
avatar

I officially suck at this game. I guess you are supposed to build a "wall" of explosions, as big as possible, that lasts as long as possible. I constantly end up with a couple of explosions near my launching site, disabling my launcher... and then I still try to launch... leading to an immediate explosion...

Yes well, legibility and correct punctuation might not be "street"... but that's how I roll, motherfucker.
However subtle, varied and subversive pop has become, it still is in essence the "Proletkult" of capitalism. -R. van der Veen

Edgar Reynaldo
Member #8,592
May 2007
avatar

Edgar said:

Is this right?

gcc -shared -Wl,-soname,libmylibrary.so.1 -o libmylibrary.so $(OBJS)

No, the names are backwards - it should be :

gcc -shared -Wl,-soname,libmylib.so.majorversion -o libmylib.so.majorversion.minorversion $(OBJS)

And then you create symbolic links :

ln -sf libmylib.so.majorversion.minorversion libmylib.so.majorversion
ln -sf libmylib.so.majorversion libmylib.so

And that allows you to link the currently symlinked real .so file (libmylib.so.majorversion.minorversion) by linking with the symlink instead (libmylib.so {-lmylib}).

weapon_S said:

I officially suck at this game. I guess you are supposed to build a "wall" of explosions, as big as possible, that lasts as long as possible. I constantly end up with a couple of explosions near my launching site, disabling my launcher... and then I still try to launch... leading to an immediate explosion...

Yeah, if you get behind, it's hard to catch back up when your own missiles are blowing up right next to your launcher. In the original game, it was only one missile every 10 seconds or so, and you had several attempts to shoot it down before it hit your city. I will adjust the config file sometime soon so that there is a better range of difficulty, I just haven't had time yet.

@Matthew
Well, it took almost a week, but I finally have a working build system for my Eagle library. And, an almost working build for Skyline on *nix. You have to static link it for now because my dynamic .so files aren't working quite right just yet.

So, if anyone wants to build Skyline themselves, now they can.
Steps :

mkdir Eagle
cd Eagle
svn checkout "http://svn.code.sf.net/p/eaglegui/code/trunk eaglegui-code"
(sudo) (mingw32-)make install STATICLINK=1
cd ..
mkdir Skyline
cd Skyline
svn checkout "http://svn.code.sf.net/p/skylinedefense/code/trunk skylinedefense-code"
(mingw32-)make STATICLINK=1
(./)Skyline_static(.exe)

TL;DR:
Build Skyline yourself! Contribute patches to Eagle or Skyline if you want to! Now that I have the build systems mostly done, I can get back to working on the programs! So maybe I'll have an update soon. :)

C/C++ Reference -|- cplusplus.com - The C++ Resources Network -|- SGI's STL guide
Proverbs 15:33 The reverence of the LORD is the instruction of wisdom; And before honour is humility.
My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense)

Go to: