Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » SantaHack 2011

This thread is locked; no one can reply to it. rss feed Print
SantaHack 2011
Mark Oates
Member #1,146
March 2001
avatar

Hmm...

should I hit the abort button, or the code-in-a-panic button? :-/

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Arthur Kalliokoski
Second in Command
February 2005
avatar

Quitters never win... Hit the code-in-a-panic button.

They all watch too much MSNBC... they get ideas.

Desmond Taylor
Member #11,943
May 2010
avatar

You can do it guys :D Just keep your mind on the ball :P

Dario ff
Member #10,065
August 2008
avatar

Code Mark, code! >:(

EDIT: I'm almost ready, but I don't know if the game is building correctly. :-/ When I use the makefile from SH2011, I get these errors(MinGW 3.4.5 Win Xp SP3):

g++: `pkg-config: No such file or directory
g++: allegro-5.0: No such file or directory
g++: allegro_acodec-5.0: No such file or directory
g++: allegro_audio-5.0: No such file or directory
g++: allegro_color-5.0: No such file or directory
g++: allegro_font-5.0: No such file or directory
g++: allegro_image-5.0: No such file or directory
g++: allegro_main-5.0: No such file or directory
g++: allegro_memfile-5.0: No such file or directory
g++: allegro_physfs-5.0: No such file or directory
g++: allegro_primitives-5.0: No such file or directory
g++: allegro_ttf-5.0`: No such file or directory

Now I dunno about pkg-config, but this is another mingw install I did after doing a clean format some weeks ago. I would test if it works on my old Ubuntu VM, but it doesn't seem to boot up either. Is my compiler just screwed up?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Thomas Fjellstrom
Member #476
June 2000
avatar

I don't think pkg-config is meant to be used on windows? Also `backticks` don't work on windows.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Dario ff
Member #10,065
August 2008
avatar

I know, right? :o I'm just using the SH2011 makefile from the template for A5. Do you mind trying compiling it yourself? I'm in need of a Linux box to test. :P

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

kdevil
Member #1,075
March 2001
avatar

Sounds like you don't have the WINDOWS or MINGDIR environment variables set. Somewhere in the system part of the Windows control panel there's a place where you can set environment variables like that.

-----
"I am the Black Mage! I casts the spells that makes the peoples fall down!"

Matthew Leverton
Supreme Loser
January 1999
avatar

You should be able to do it on the command line:

make WINDOWS=1

or whatever the makefile wants.

Desmond Taylor
Member #11,943
May 2010
avatar

Well, I hope mine compiles okay. It does when using Code::Blocks but haven't tested the makefile as I have no idea how :/ It compiles with 5.0.5 though :D

Dario ff
Member #10,065
August 2008
avatar

You should be able to do it on the command line:make WINDOWS=1

or whatever the makefile wants.

Yeah that worked. And indeed, it seems I had forgotten the MINGDIR enviroment variable after I did this clean Windows install.

Now all that remains is finding someone who can try it on Linux that isn't part of the compo. Anyone?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

MiquelFire
Member #3,110
January 2003
avatar

Dario ff said:

Now all that remains is finding someone who can try it on Linux that isn't part of the compo. Anyone?

Makes me wish I had a Linux system.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Matthew Leverton
Supreme Loser
January 1999
avatar

If you send me a PM with a link I'll try it out. :o

Dario ff
Member #10,065
August 2008
avatar

Sent. I'm gonna go battle with vmware meanwhile. :P

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Matthew Leverton
Supreme Loser
January 1999
avatar

It worked, but only when I linked against the debug version of Allegro.

Otherwise it complained about not being able to load the ogg tracks. My release library does have ogg support, but it could just be due to something I broke while hacking on Allegro.

Edit:

There is a box (missing character in the font?) at the end of some of the text strings. e.g., After the name of the level.

Sucess is misspelled.

Dario ff
Member #10,065
August 2008
avatar

The makefile is the one from SH2011 with the game name modified. I compiled the release version with the binaries from the Files page on Windows just fine. I'm downloading a newer version of VMWare at the moment to test it out.

Thanks for that, I'm gonna just guess the OGG issue is just a problem in your setup. :P

EDIT:

There is a box (missing character in the font?) at the end of some of the text strings. e.g., After the name of the level.Sucess is misspelled.

That's my ignorance at work. BRB. :P

EDIT2: I think the box thing is related to my own ignorance of how text file reading is handled on Linux. :-/

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

l j
Member #10,584
January 2009
avatar

Dario ff said:

EDIT2: I think the box thing is related to my own ignorance of how text file reading is handled on Linux.

Windows uses CR/LF to indicate a new line. (If you aren't aware, CR = carriage return, LF = line feed)
While linux only uses a CR (or was it LF? not sure anymore). The extra box being rendered is probably the LF.

Thomas Fjellstrom
Member #476
June 2000
avatar

Old mac was CR (aka \r) only. Unix is LF (aka \n).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Dario ff
Member #10,065
August 2008
avatar

Ok, so say I'm using fgets for reading from the text file, what would be the cross-platform way to read each line and make sure there are no newline characters?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Here's how I do cross platform line reading (only works in BINARY file mode! (don't know why - I think it's something to do with the way file seeking works)) :

FileWork.hpp

#SelectExpand
1 2#ifndef FileWork_H 3#define FileWork_H 4 5 6#include <string> 7#include <cstdio> 8#include <iostream> 9 10 11 12// Platform neutral getline - reads up unti EOF, \r (OSX), \r\n (WIN), or \n (NIX) 13// May only work in BINARY MODE. 14std::istream& GetLinePN(std::istream& is , std::string& s); 15// Same as above, but ONLY works in BINARY MODE! 16FILE* GetLinePN(FILE* f , std::string& s); 17 18void SkipWhiteSpace(FILE* f); 19bool ReadTextInteger(FILE* f , int* store); 20 21// ONLY works in BINARY MODE! 22int fpeek(FILE* f); 23 24 25 26 27#endif // FileWork_H

FileWork.cpp

#SelectExpand
1 2 3#include <allegro5/allegro.h> 4 5#include "Eagle5/FileWork.hpp" 6 7using std::string; 8 9 10 11std::istream& GetLinePN(std::istream& is , std::string& s) { 12 s = ""; 13 char c; 14 if (!is.good()) {return is;} 15 while (!((is.get(c)).eof())) { 16 if (c == '\r') {// WINDOWS OR OSX 17 int c2 = is.peek(); 18 if (c2 == '\n') { 19 is.get(c);// use up \n 20 } 21 return is; 22 } 23 if (c == '\n') {// NIX 24 return is; 25 } 26 s += c; 27 } 28 return is; 29} 30 31 32 33FILE* GetLinePN(FILE* f , std::string& s) { 34 s = ""; 35 if (!f || feof(f) || ferror(f)) {return f;} 36 int c; 37 while ((c = fgetc(f)) != EOF) { 38 if (c == '\r') {// WINDOWS OR OSX 39 int c2 = fpeek(f); 40 if (c2 == '\n') { 41 c = fgetc(f);// use up \n 42 } 43 return f; 44 } 45 if (c == '\n') {// NIX 46 return f; 47 } 48 s += c; 49 } 50 return f; 51} 52 53 54 55void SkipWhiteSpace(FILE* f) { 56 int c = 0; 57 while (1) { 58 c = fgetc(f); 59 if (!((c == ' ') || 60 (c == '\t') || 61 (c == '\n') || 62 (c == '\f') || 63 (c == '\r'))) { 64 // not whitespace 65 if (c != EOF) { 66 ungetc(c , f); 67 } 68 break; 69 } 70 } 71} 72 73 74bool ReadTextInteger(FILE* f , int* store) { 75 ASSERT(store); 76 77 string s; 78 int i = 0; 79 bool isnumber = false; 80 81 while (1) { 82 int c = fgetc(f); 83 if (isdigit(c)) { 84 isnumber = true; 85 s += (char)c; 86 } else { 87 if (c != EOF) { 88 ungetc(c , f); 89 } 90 break; 91 } 92 } 93 94 if (isnumber) { 95 i = atoi(s.c_str()); 96 *store = i; 97 return true; 98 } 99 100 return false; 101} 102 103 104int fpeek(FILE* f) { 105 if (!f || feof(f) || ferror(f)) {return EOF;} 106 long pos = ftell(f); 107 int c = fgetc(f); 108 fseek(f , pos , SEEK_SET); 109 ALLEGRO_ASSERT(pos == ftell(f)); 110 return c; 111}

The only thing allegro is used for is an ALLEGRO_ASSERT - remove that, and you don't need A5.

There's a version for istream, and for FILE*.

Dario ff
Member #10,065
August 2008
avatar

Oh neat, thanks, although I did find a snippet already. And only working in binary mode is a problem. :-/

Lesson learned, XML is probably the best solution to everything. >:(

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

l j
Member #10,584
January 2009
avatar

I just use the allegro config stuff, works pretty well for me.

GullRaDriel
Member #3,861
September 2003
avatar

Various problem including internet access have made my entry null. Sorry.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

l j
Member #10,584
January 2009
avatar

I'm trying to find motivation to finish this, but somehow I feel stressed and can't get shit done at all...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar



Go to: