@ -0,0 +1,22 @@ |
|||
_Buzzer Statates:_ |
|||
|
|||
+-------------------------------+-----+-----+ |
|||
|Buzzer State | Int | Hex | |
|||
+-------------------------------+-----+-----+ |
|||
+-------------------------------+-----+-----+ |
|||
|No Buzzer pushed | 239 | ef | |
|||
+-------------------------------+-----+-----+ |
|||
|All Buzzers pushed | 15 | f | |
|||
+===============================+=====+=====+ |
|||
|Buzzer without color tag pushed| 207 | cf | |
|||
+-------------------------------+-----+-----+ |
|||
|Green Buzzer pushed | 175 | af | |
|||
+-------------------------------+-----+-----+ |
|||
|Red Buzzer pushed | 111 | 6f | |
|||
+===============================+=====+=====+ |
|||
|Red & no tag Buzzer pushed | 79 | 4f | |
|||
+-------------------------------+-----+-----+ |
|||
|Green & red Buzzer pushed | 47 | 2f | |
|||
+-------------------------------+-----+-----+ |
|||
|Green & no tag Buzzer pushed | 143 | 8f | |
|||
+-------------------------------+-----+-----+ |
@ -0,0 +1,57 @@ |
|||
Topic: /etc/magic |
|||
Frage: Rar! |
|||
Antwort: RAR |
|||
Frage: -lh |
|||
Antwort: LHA |
|||
Frage: jP |
|||
Antwort: JPEG |
|||
Frage: CWS |
|||
Antwort: Flash |
|||
Frage: d8:announce |
|||
Antwort: BitTorrent |
|||
|
|||
Topic: Quotes |
|||
Frage: 640 kB sollten eigentlich genug für jeden sein |
|||
Antwort: Bill Gates |
|||
Frage: Alles ist eins - außer der Null. |
|||
Antwort: Wau Holland |
|||
Frage: In der Informatik geht es genau so wenig um Computer, wie in der Astronomie um Teleskope. |
|||
Antwort: Edsger W. Dijkstra |
|||
Frage: Computer sind nutzlos, sie können uns nur Antworten geben. |
|||
Antwort: Pablo Picasso |
|||
Frage: Der Computer rechnet mit allem, nur nicht mit seinem Besitzer. |
|||
Antwort: Dieter Hildebrandt |
|||
|
|||
Topic: Autoren |
|||
Frage: The art of computer programming |
|||
Antwort: Welches beruehmte Computerbuch hat Donald Knuth geschrieben? |
|||
Frage: Operating Systems: Design and Implementation |
|||
Antwort: Welches bekannte Buch hat Andrew S. Tannenbaum ueber Betriebsysteme/Minix geschrieben? |
|||
Frage: The Design and Implementation of the FreeBSD Operating System |
|||
Antwort: Welches Buch hat Marshall McKusick ueber FreeBSD geschrieben? |
|||
Frage: User Friendly |
|||
Antwort: Welcher Comic wurde von Illiad geschaffen? |
|||
|
|||
Topic: Serien |
|||
Frage: Bel-Air |
|||
Antwort: in welcher Vorstadt wohnt will Smiths Onkel Philip Banks. |
|||
Frage: Home Improvement |
|||
Antwort: der Originalname der Serie des Schauspieler Tim Allen |
|||
Frage: Resi Berghammer |
|||
Antwort: der Filmname der Mutter von Ottfried Fischer? |
|||
Frage: Maxwell Sheffield |
|||
Antwort: der Serienname des Hauptdarstellers von The Nanny |
|||
Frage: Lost |
|||
Antwort: Jemand wacht in einem Dschungel auf... |
|||
|
|||
Topic: Programmmaskotchen |
|||
Frage: BSD |
|||
Antwort:Chuck ist das Maskotchen welches Betribsystem |
|||
Frage: MSN |
|||
Antwort: Der MSN-Schmeterling flattert fÃŒr? |
|||
Frage: OpenBsd |
|||
Antwort:FÃŒr was wirbt Buffy der Kugelfisch ? |
|||
Frage: Tux |
|||
Antwort: Was ist das Maskotchen von Linux |
|||
Frage: KDE |
|||
Antwort: Von welcher Graphischer-BenuzeroberflÀche ist Konqui das Maskotchen. |
@ -0,0 +1,237 @@ |
|||
Topic: Getränke |
|||
Frage: Aus eine in Südamerika seit Jahrhunderten verwendeten Urwaldpflanze die Koffein enthält. |
|||
Antwort: Woraus besteht Club-Mate? |
|||
Frage: u.A. Koffein, Phosphorsäure, Kohlensäure und große Mengen Zucker |
|||
Antwort: Woraus besteht Cola? |
|||
Frage: englischer Ausdruck für Elfe oder Kobold. |
|||
Antwort: Was ist Sprite? |
|||
Frage: Zählt in Russland seit einigen Jahren offiziell zu den nichtalkoholischen Getränken. |
|||
Antwort: Was ist Bier? |
|||
Frage: Hydrogeniumoxid (oder auch Dihydrogeniumoxid) |
|||
Antwort: Was ist Wasser (H2O)? |
|||
|
|||
Topic: Programmargumente |
|||
Frage: Kein newline am Ende der `echo` Ausgabe. |
|||
Antwort: Was macht echo -n |
|||
Frage: TCP SYN stealth port scan mit nmap. |
|||
Antwort: Was macht nmap -sS? |
|||
Frage: Emuliere rlogin mit telnet. |
|||
Antwort: Was macht telnet -r? |
|||
Frage: ls Ausgabe in nur einer Spalte. |
|||
Antwort: Was macht ls -1 |
|||
Frage: Gepunkteter Fortschrittsbalken in wget. |
|||
Antwort: Was macht wget --progress=dot |
|||
|
|||
Topic: "entropia" kodiert |
|||
Frage: aiportne |
|||
Antwort: Was ist entropia rückwärts? |
|||
Frage: hqwursld |
|||
Antwort: Was ist Caesar? |
|||
Frage: ragebcvn |
|||
Antwort: Was ist rot13? |
|||
Frage: ZW50cm9waWE= |
|||
Antwort: Was ist base64? |
|||
Frage: ade530f0d2cc51586d8e395c4b390cc1 |
|||
Antwort: Was ist md5? |
|||
|
|||
Übersetzungen: |
|||
Frage: Keks |
|||
Antwort: cookie |
|||
Frage: Sauganleger |
|||
Antwort: sniffer |
|||
Frage: Gebrochene Pfeiffe |
|||
Antwort: broken pipe |
|||
Frage: Kernspeicherabzug |
|||
Antwort: core dump |
|||
Frage: Alternativkontrollöschung |
|||
Antwort: CTRL-ALT-DEL |
|||
|
|||
Topic: Programmiersprachen |
|||
Frage: C++ |
|||
Antwort: cout << "Aller Anfang ist leicht!" << endl; |
|||
Frage: Haskell |
|||
Antwort: [y | y <- xs, y <= x] |
|||
Frage: WSPL (White Space Programming Language) |
|||
Antwort: |
|||
Frage: Ook |
|||
Antwort: Ook. Ook? Ook! Ook? Ook! Ook! |
|||
Frage: HQ9+ |
|||
Antwort: 9 |
|||
|
|||
Topic: /etc/magic |
|||
Frage: RAR |
|||
Antwort: Rar! |
|||
Frage: LHA |
|||
Antwort: -lh |
|||
Frage: JPEG |
|||
Antwort: jP |
|||
Frage: Flash |
|||
Antwort: CWS |
|||
Frage: BitTorrent |
|||
Antwort: d8:announce |
|||
|
|||
Topic: Quotes |
|||
Frage: Bill Gates |
|||
Antwort: 640 kB sollten eigentlich genug für jeden sein |
|||
Frage: Wau Holland |
|||
Antwort: Alles ist eins - außer der Null. |
|||
Frage: Edsger W. Dijkstra |
|||
Antwort: In der Informatik geht es genau so wenig um Computer, wie in der Astronomie um Teleskope. |
|||
Frage: Pablo Picasso |
|||
Antwort: Computer sind nutzlos, sie können uns nur Frageen geben. |
|||
Frage: Dieter Hildebrandt |
|||
Antwort: Der Computer rechnet mit allem, nur nicht mit seinem Besitzer. |
|||
|
|||
Topic: Autoren |
|||
Frage: The art of computer programming |
|||
Antwort: Welches beruehmte Computerbuch hat Donald Knuth geschrieben? |
|||
Frage: Operating Systems: Design and Implementation |
|||
Antwort: Welches bekannte Buch hat Andrew S. Tannenbaum ueber Betriebsysteme/Minix geschrieben? |
|||
Frage: The Design and Implementation of the FreeBSD Operating System |
|||
Antwort: Welches Buch hat Marshall McKusick ueber FreeBSD geschrieben? |
|||
Frage: User Friendly |
|||
Antwort: Welcher Comic wurde von Illiad geschaffen? |
|||
|
|||
Topic: Serien |
|||
Frage:in welcher Vorstadt wohnt will Smiths Onkel Philip Banks. |
|||
Antwort:Bel-Air |
|||
Frage:der Originalname der Serie des Schauspieler Tim Allen |
|||
Antwort: Home Improvement |
|||
Frage: der Filmname der Mutter von Ottfried Fischer? |
|||
Antwort: Resi Berghammer |
|||
Frage: der Serienname des Hauptdarstellers von The Nanny |
|||
Antwort: Maxwell Sheffield |
|||
Frage: Jemand wacht in einem Dschungel auf... |
|||
Antwort: Lost |
|||
|
|||
Topic: Programmmaskotchen |
|||
Frage: BSD |
|||
Antwort:Chuck ist das Maskotchen welches Betribsystem |
|||
Frage: MSN |
|||
Antwort: Der MSN-Schmeterling flattert fÃŒr? |
|||
Frage: OpenBsd |
|||
Antwort:FÃŒr was wirbt Buffy der Kugelfisch ? |
|||
Frage: Tux |
|||
Antwort: Was ist das Maskotchen von Linux |
|||
Frage: KDE |
|||
Antwort: Von welcher Graphischer-BenuzeroberflÀche ist Konqui das Maskotchen. |
|||
|
|||
Topic: Cheats |
|||
Frage: GABBAGBBAHEY |
|||
Antwort: Wie aktiviere ich die cheats in Descent |
|||
Frage: Havneluder |
|||
Antwort: Wie werde ich in Earth Worm Jim2 unverwundbar |
|||
Frage: F10+G, F10 + I, F10 + J |
|||
Antwort: Wie lauten die Cheats in Comander Keen |
|||
Frage: IDDQD |
|||
Antwort: Wie komme ich in den God Mode in Doom? |
|||
Frage: \God |
|||
Antwort: Wie macht man sich in Quake 3 Unbeliebt? |
|||
|
|||
Topic: Acronyme |
|||
Frage: MARS |
|||
Antwort: Was ist ein Memory Array Redcode Simulator? |
|||
Frage: VI |
|||
Antwort: Was ist ein Visual Interface? |
|||
Frage: SCUMM |
|||
Antwort: Was ist das Script Creation Utility for Maniac Mansion? |
|||
Frage: WYSINWYG |
|||
Antwort: Was ist "What you see is nearly what you get"? |
|||
Frage: SNAFU-Prinzip |
|||
Antwort: Was bedeutet "Situation normal, all Fucked up"? |
|||
|
|||
Topic: Religion |
|||
Frage: Kein Genie |
|||
Antwort: Was ist die Aufnamebedienung in die Church of Subgenius |
|||
Frage: Eine Kakerlake |
|||
Antwort: Wer ist St. Gulik / Hermes |
|||
Frage: Hot Dog |
|||
Antwort: Was darf mann als Discordist höchstens Freitags essen |
|||
Frage: Kalisti |
|||
Antwort: Was stand auf dem Apfel, Was heißt "für die schönste" in Griechisch |
|||
Frage: J.R. "Bob" Dobbs |
|||
Antwort: wie heißt das Oberhaubt der Church of the subgenius |
|||
|
|||
Topic: strange programming |
|||
Frage: ($eval=$=)=~s;(f);$1->eval;,undef$=;eval"map eval()=>$eval"; |
|||
Antwort: Wie macht man Spaß mit eval() in Perl? |
|||
Frage: =IF((AND(D2>5,C2>10000)),2,1) |
|||
Antwort: Wie sehen Excels IF-Statements aus? |
|||
Frage: ipart=${mod/%.*}; fpart=${mod/#*.}; places=${#fpart}; |
|||
Antwort: Wie macht man Pattern-Matching in bash? |
|||
Frage: class O(float):O,__new__=0,lambda O,_:O.__setattr__(O,"O",_+O.O)or O.O |
|||
Antwort: Wie sieht Obfuscated Python aus? |
|||
Frage: DO :1 <- #0¢#256 |
|||
Antwort: Wie weist man in INTERCAL Werte zu? |
|||
|
|||
Topic: T9 |
|||
Frage: 222 |
|||
Antwort: Was ist CCC in T9? |
|||
Frage: 476 |
|||
Antwort: Was ist GPN in T9? |
|||
Frage: 422536 |
|||
Antwort: Was ist HACKEN in T9? |
|||
Frage: 25776641 |
|||
Antwort: Was ist Entropia in T9? |
|||
Frage: 524532477 |
|||
Antwort: Was ist Neingeist in T9? |
|||
|
|||
Topic: Linux /dev |
|||
Frage: /dev/null |
|||
Antwort: Was ist der Mlleimer? |
|||
Frage: /dev/fd1 |
|||
Antwort: Was ist das zweite Floppy-Device? |
|||
Frage: /dev/sr0 |
|||
Antwort: Was ist das erste SCSI-CDROM? |
|||
Frage: /dev/vcs |
|||
Antwort: Was ist Virtual Console Memory? |
|||
Frage: /dev/full |
|||
Antwort: Was gibt: No space left on device? |
|||
|
|||
Topic: Releasedates |
|||
Frage: IBM PC |
|||
Antwort: 1981 |
|||
Frage: C64 |
|||
Antwort: 1982 |
|||
Frage: Imac |
|||
Antwort: 1998 |
|||
Frage: VAX |
|||
Antwort: 1977 |
|||
Frage: PDP11 |
|||
Antwort: 1970 |
|||
|
|||
C64: |
|||
Frage: SID |
|||
Antwort: Soundchip |
|||
Frage: VIC |
|||
Antwort: Grafikchip |
|||
Frage: 1541 |
|||
Antwort: Floppylaufwerk |
|||
Frage: CIA |
|||
Antwort: IO Port |
|||
Frage: 9152 |
|||
Antwort: Startadresse von SID Musikstuecken |
|||
|
|||
Topic: UNIX-Kommandos |
|||
Frage: bc |
|||
Antwort: Was ist ein Taschenrechner? |
|||
Frage: mknod |
|||
Antwort: Wie legt man Device-Nodes an? |
|||
Frage: m4 |
|||
Antwort: Was ist ein Makro-Prozessor? |
|||
Frage: [ |
|||
Antwort: Was ist ein Alias fr test(1)? |
|||
Frage: od |
|||
Antwort: Wie dumpt man Dateien oktal? |
|||
|
|||
Topic: TLDs |
|||
Frage: heise |
|||
Antwort: Was ist .de? |
|||
Frage: slashdot |
|||
Antwort: Was ist .org? |
|||
Frage: freshmeat |
|||
Antwort: Was ist .net? |
|||
Frage: securityfocus |
|||
Antwort: Was ist .com? |
|||
Frage: setiathome.ssl.berkeley |
|||
Antwort: Was ist .edu? |
@ -0,0 +1,7 @@ |
|||
Inputfiles sind wie folgt augebaut: |
|||
"Topic: <Irgendwas>" Gibt das Thema vor. |
|||
"Frage: <Irgendwas>" Stellt die Frage bzw. die Antwort die den Probanten serviert wird. |
|||
"Antwort: <irgendwas>" Gibt die Gesuchte Frage an. |
|||
|
|||
Es muessen 5 Topics, und zu jedem Topic 5 Fragen und Antworten vorhanden sein. |
|||
Diese koennen aber leer sein. |
@ -0,0 +1,55 @@ |
|||
Topic: Acronyme |
|||
Frage: RTFM |
|||
Antwort: Read the fucking manual |
|||
Frage: LART |
|||
Antwort: Luser Automatic Rearrangement Tool |
|||
Frage: UTSL |
|||
Antwort: use the source, luke |
|||
Frage: YMMV |
|||
Antwort: Your mileage may vary |
|||
Frage: IANAL |
|||
Antwort: I am not a lawyer |
|||
Topic: Releasedates |
|||
Frage: IBM PC |
|||
Antwort: 1981 |
|||
Frage: C64 |
|||
Antwort: |
|||
Frage: Imac |
|||
Antwort: 1998 |
|||
Frage: VAX |
|||
Antwort: 1977 |
|||
Frage: PDP11 |
|||
Antwort: 1970 |
|||
Topic: Kryptographie |
|||
Frage: A -> C, B -> D, C -> E, D -> F |
|||
Antwort: Caesarchiffre |
|||
Frage: AES-Gewinner |
|||
Antwort: Rijndael |
|||
Frage: Rivest, Shamir, Adelman |
|||
Antwort: RSA |
|||
Frage: Twofish Entwickler |
|||
Antwort: Counterpane |
|||
Frage: PHT |
|||
Antwort: Pseudo Haddamard Transformation |
|||
Topic: C64 |
|||
Frage: SID |
|||
Antwort: Soundchip |
|||
Frage: VIC |
|||
Antwort: Grafikchip |
|||
Frage: 1541 |
|||
Antwort: Floppylaufwerk |
|||
Frage: CIA |
|||
Antwort: IO Port |
|||
Frage: 9152 |
|||
Antwort: Startadresse von SID Musikstuecken |
|||
Topic: Acronyme |
|||
Frage: DNS |
|||
Antwort: Domain Name System |
|||
Frage: GPN |
|||
Antwort: Gulaschprogrammiernacht |
|||
Frage: COPS |
|||
Antwort: Common Open Policy Service |
|||
Frage: ARPA |
|||
Antwort: Adress and Routing Parameter Area Domain |
|||
Frage: LAT |
|||
Antwort: Local Area Transport |
@ -0,0 +1,55 @@ |
|||
Topic: Acronyme |
|||
Frage: PC |
|||
Antwort: Personal Computer |
|||
Frage: FTP |
|||
Antwort: File Transfer Protocol |
|||
Frage: DMZ |
|||
Antwort: Demilitarized Zone |
|||
Frage: EMACS |
|||
Antwort: EIGHTHUNDRED MEGABYTES AND CONTINUOUSLY SWAPPING |
|||
Frage: ASCII |
|||
Antwort: American Standard Code For Information Interchange |
|||
Topic: Hackerfilme |
|||
Frage: Du Nullprogramm! |
|||
Antwort: Tron |
|||
Frage: How about Global Thermonuclear War? |
|||
Antwort: Wargames |
|||
Frage: Close this world, open the next |
|||
Antwort: Lain |
|||
Frage: It's not just a chip, it also has a PCI bus! |
|||
Antwort: Hackers |
|||
Frage: If we graph the numbers of any system, patterns emerge. |
|||
Antwort: Pi |
|||
Topic: Acronyme |
|||
Frage: RTFM |
|||
Antwort: Read the fucking manual |
|||
Frage: LART |
|||
Antwort: Luser Automatic Rearrangement Tool |
|||
Frage: UTSL |
|||
Antwort: use the source, luke |
|||
Frage: YMMV |
|||
Antwort: Your mileage may vary |
|||
Frage: IANAL |
|||
Antwort: I am not a lawyer |
|||
Topic: Prozessoren |
|||
Frage: PC/AT |
|||
Antwort: 8086 |
|||
Frage: E450 |
|||
Antwort: Ultrasparc |
|||
Frage: Atari 1040ST |
|||
Antwort: 68000 |
|||
Frage: IBM SP256 |
|||
Antwort: PPC |
|||
Frage: Connection Machine 5 |
|||
Antwort: Sparc |
|||
Topic: Softwareauthoren |
|||
Frage: qmail |
|||
Antwort: djb |
|||
Frage: tex |
|||
Antwort: Knuth |
|||
Frage: fetchmail |
|||
Antwort: Eric Raymond |
|||
Frage: gcc |
|||
Antwort: Richard Stallman |
|||
Frage: vi |
|||
Antwort: Bill Joy |
@ -0,0 +1,9 @@ |
|||
CC = gcc -Wall -ansi |
|||
|
|||
all: |
|||
$(CC) sdljpd.c -o sdljpd -lm -lSDL_image -lSDL_ttf `sdl-config --cflags --libs` -lSDL_mixer -g |
|||
|
|||
clean: |
|||
@echo Cleaning up... |
|||
@rm sdljpd |
|||
@echo Done. |
@ -0,0 +1,9 @@ |
|||
CC = gcc -Wall -ansi |
|||
|
|||
all: |
|||
$(CC) sdljpd.c -o sdljpd -lm -lSDL_image -lSDL_ttf `sdl-config --cflags --libs` -lSDL_mixer -g -B/usr/lib/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu |
|||
|
|||
clean: |
|||
@echo Cleaning up... |
|||
@rm sdljpd |
|||
@echo Done. |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,3 @@ |
|||
#! /bin/sh |
|||
chown root:root sdljpd |
|||
chmod a+s sdljpd |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 377 KiB |
After Width: | Height: | Size: 60 KiB |
@ -0,0 +1,858 @@ |
|||
/***************************************************************************
|
|||
sdljpd.c - Jeopardy on steroids |
|||
------------------- |
|||
begin : So 15 Mai 2005 |
|||
copyright : (C) 2004 by Frederick Bullik |
|||
email : Frederick.Bullik@web.de |
|||
***************************************************************************/ |
|||
/***************************************************************************
|
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU General Public License as published by * |
|||
* the Free Software Foundation; either version 2 of the License, or * |
|||
* (at your option) any later version. * |
|||
* * |
|||
***************************************************************************/ |
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <unistd.h> /*include datei die das Komandozeilen handling vereinfacht*/ |
|||
#include <time.h> |
|||
#include <math.h> |
|||
#include <sys/io.h> |
|||
|
|||
#include "SDL.h" |
|||
#include "SDL_image.h" |
|||
#include "SDL_ttf.h" |
|||
#include "SDL_mixer.h" |
|||
|
|||
/* Define our booleans */ |
|||
#define TRUE 1 |
|||
#define FALSE 0 |
|||
|
|||
#define RENDER_MODE 2 //0=solid 1=shaded 2=blended
|
|||
|
|||
/* screen width, height, and bit depth */ |
|||
/** \brief Die Bildschirmbreite fuer den Fenstermodus */ |
|||
#define SCREEN_WIDTH 1024 |
|||
/** \brief Die Bildschirmhohe fuer den Fenstermodus */ |
|||
#define SCREEN_HEIGHT 768 |
|||
/** \brief Farbtiefe des Bildschirmes */ |
|||
#define SCREEN_BPP 24 |
|||
|
|||
/* make prototype of getopt because of "implicit declaration" */ |
|||
int getopt(int argc, char * const argv[], const char *optstring); |
|||
extern char *optarg; |
|||
extern int optind, opterr, optopt; |
|||
|
|||
char xpfp[1000]; |
|||
char buf[10000]; |
|||
char pl1[1000]; |
|||
char pl2[1000]; |
|||
char pl3[1000]; |
|||
char blub[1000]; |
|||
|
|||
int enp = FALSE; |
|||
int inp = FALSE; |
|||
signed int score[3] ={0,0,0}; |
|||
int scorebuf; |
|||
int plselect = 0; |
|||
int lockbz = FALSE; |
|||
int port_adr; |
|||
int xpos = 0, ypos = 0; |
|||
int solved[5][5] = {{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}}; |
|||
int pkt[5] = {100,200,300,400,500}; |
|||
int artype; |
|||
int countxa = 0; |
|||
int countya = 0; |
|||
int countxf = 0; |
|||
int countyf = 0; |
|||
int countxt = 0; |
|||
|
|||
FILE *file; |
|||
|
|||
typedef struct s_block{ |
|||
char frage[10000]; |
|||
char antwort[1000]; |
|||
} t_block; |
|||
|
|||
typedef struct { |
|||
char katname[1000]; |
|||
} t_kat; |
|||
|
|||
t_block myblock[5][5]; |
|||
t_kat mykat[5]; |
|||
|
|||
Mix_Music *music = NULL; |
|||
|
|||
|
|||
/** \brief This is our SDL surface
|
|||
* |
|||
* Unser Haupt SDL Surface |
|||
*/ |
|||
SDL_Surface *surface; /*Display Surface*/ |
|||
SDL_Surface *kachel; /*hintergrund fuer die Fragefelder*/ |
|||
SDL_Surface *bgrnd; /*makriert blockierte Felder */ |
|||
SDL_Surface *nfield; /*Score, Namensfekder der Spieler*/ |
|||
SDL_Surface *plac; /*kenzeichnung acktiver Spierler*/ |
|||
SDL_Surface *afr; /*kenzeichnung des aktives fragen feldes */ |
|||
SDL_Surface *text; |
|||
SDL_Surface *panel; |
|||
|
|||
SDL_Rect drect; |
|||
|
|||
SDL_Color color={255,125,0}; |
|||
|
|||
TTF_Font *font; |
|||
|
|||
/** \brief Hier Raeumen wir nach Programablauf auf.
|
|||
* |
|||
* \param returnCode Der Zurueckzugebende Return Code |
|||
* \return Gibt den Uebergebenen Code aus |
|||
*/ |
|||
/* function to release/destroy our resources and restoring the old desktop */ |
|||
void Quit( int returnCode ) |
|||
{ |
|||
Mix_HaltMusic(); |
|||
Mix_FreeMusic(music); |
|||
music = NULL; |
|||
|
|||
SDL_FreeSurface(panel); |
|||
SDL_FreeSurface(text); |
|||
SDL_FreeSurface(afr); |
|||
SDL_FreeSurface(plac); |
|||
SDL_FreeSurface(nfield); |
|||
SDL_FreeSurface(kachel); |
|||
SDL_FreeSurface(bgrnd); |
|||
SDL_FreeSurface(surface); |
|||
|
|||
TTF_CloseFont(font); |
|||
|
|||
TTF_Quit(); |
|||
|
|||
/* clean up the window */ |
|||
SDL_Quit( ); |
|||
|
|||
/*fclose(file);*/ |
|||
|
|||
|
|||
printf("\033[33m sdljpd:\033[m So long, and thanks for all the fish <;))>< \n"); |
|||
|
|||
/* and exit appropriately */ |
|||
exit( returnCode ); |
|||
} |
|||
|
|||
void musicDone(void){ |
|||
Mix_HaltMusic(); |
|||
Mix_FreeMusic(music); |
|||
music = NULL; |
|||
music = Mix_LoadMUS("bgmusic-loop.wav"); |
|||
Mix_PlayMusic(music, -1); |
|||
} |
|||
|
|||
void music_init(void){ |
|||
if(music == NULL) { |
|||
music = Mix_LoadMUS("bgmusic-intro.wav"); |
|||
Mix_PlayMusic(music, 0); |
|||
Mix_HookMusicFinished(musicDone); |
|||
} |
|||
|
|||
} |
|||
|
|||
void filefill(void) |
|||
{ |
|||
|
|||
if(artype == 1) |
|||
{ |
|||
strcpy(mykat[countxt].katname,blub); |
|||
countxt ++; |
|||
blub[0] = '\0'; |
|||
|
|||
} |
|||
|
|||
if(artype == 2) |
|||
{ |
|||
strcpy(myblock[countxf][countyf].frage,blub); |
|||
countyf ++; |
|||
blub[0] = '\0'; |
|||
|
|||
if(countyf >4) |
|||
{ |
|||
countyf = 0; |
|||
countxf ++; |
|||
} |
|||
} |
|||
|
|||
if(artype == 3) |
|||
{ |
|||
strcpy(myblock[countxa][countya].antwort,blub); |
|||
countya ++; |
|||
blub[0] = '\0'; |
|||
|
|||
if(countya >4) |
|||
{ |
|||
countya = 0; |
|||
countxa ++; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
void filefoo (void) |
|||
{ |
|||
|
|||
char ch[100]; |
|||
char ach; |
|||
|
|||
file = fopen(xpfp,"r"); |
|||
|
|||
if(file == NULL) |
|||
{ |
|||
fprintf(stderr, "Folgende Datei konnte nicht geladen werden:%s\n",xpfp ); |
|||
} |
|||
|
|||
|
|||
while (fscanf(file,"%s",ch) ) |
|||
{ |
|||
|
|||
if (strcmp(ch,"Topic:") == 0){ |
|||
filefill(); |
|||
artype = 1; |
|||
continue; |
|||
} |
|||
|
|||
if (strcmp(ch,"Frage:")== 0){ |
|||
filefill(); |
|||
artype = 2; |
|||
continue; |
|||
} |
|||
|
|||
if (strcmp(ch,"Antwort:") == 0){ |
|||
filefill(); |
|||
artype = 3; |
|||
continue; |
|||
} |
|||
|
|||
strcat(blub, ch); |
|||
strcat(blub, " "); |
|||
|
|||
if (fscanf(file,"%c",&ach) == EOF){ |
|||
filefill(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
fclose(file); |
|||
|
|||
} |
|||
|
|||
|
|||
int get_lp_base(void) |
|||
{ |
|||
int i, base_adr[3] = {0x3bc, 0x378, 0x278}; |
|||
|
|||
for(i=0; i<3; i++) |
|||
{ |
|||
outb_p(0, base_adr[i]); |
|||
if (inb_p(base_adr[i]) == 0) |
|||
return(base_adr[i]); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
void loadtex( void ) |
|||
{ |
|||
kachel = IMG_Load("kachel100.jpg"); |
|||
|
|||
if (kachel == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
bgrnd = IMG_Load("bgrnd100.jpg"); |
|||
|
|||
if (bgrnd == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
nfield = IMG_Load("nfield.jpg"); |
|||
|
|||
if (nfield == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
|
|||
plac = IMG_Load("sp.jpg"); |
|||
|
|||
if (plac == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
afr = IMG_Load("aq.jpg"); |
|||
|
|||
if (afr == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
panel = IMG_Load("panel1.jpg"); |
|||
|
|||
if (panel == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
} |
|||
|
|||
/*void get_buz (void)
|
|||
{ |
|||
int status; |
|||
|
|||
if(lockbz == FALSE ) |
|||
{ |
|||
status = inb(port_adr + 1); |
|||
|
|||
if(status != 239) |
|||
{ |
|||
if(status == 207) |
|||
{ |
|||
plselect = 0; |
|||
lockbz = TRUE; |
|||
} |
|||
|
|||
if(status == 175) |
|||
{ |
|||
plselect = 1; |
|||
lockbz = TRUE; |
|||
} |
|||
|
|||
if(status == 111) |
|||
{ |
|||
plselect = 2; |
|||
lockbz = TRUE; |
|||
} |
|||
} |
|||
} |
|||
}*/ |
|||
|
|||
void draw_sdl (void) |
|||
{ |
|||
int countx =0; |
|||
int county =0; |
|||
|
|||
/* Spielfeld geschlumpfe*/ |
|||
drect.w = kachel -> w; |
|||
drect.h = kachel -> h; |
|||
|
|||
SDL_SetAlpha(bgrnd, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
SDL_SetAlpha(afr, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
SDL_SetAlpha(plac, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
|
|||
/*get_buz();*/ |
|||
|
|||
SDL_FillRect(surface, NULL, 0); |
|||
|
|||
for(county=0;county<=4;county++) |
|||
{ |
|||
drect.y = (county*100) + 100; |
|||
|
|||
for(countx=0;countx<=4;countx++) |
|||
{ |
|||
drect.x = (countx*200) + 65; |
|||
|
|||
SDL_BlitSurface(kachel, NULL, surface, &drect ); |
|||
|
|||
if(solved[countx][county] == 0){ |
|||
SDL_FreeSurface(text); |
|||
sprintf(buf,"%i",pkt[county]); |
|||
/*if(pkt[county]==100){buf = "100";}
|
|||
if(pkt[county]==200){buf = "200";} |
|||
if(pkt[county]==300){buf = "300";} |
|||
f(pkt[county]==400){buf = "400";} |
|||
if(pkt[county]==500){buf = "500";}*/ |
|||
text = TTF_RenderText_Blended(font, buf,color); |
|||
drect.x = drect.x + 23; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
} |
|||
|
|||
if(solved[countx][county] >=1){ |
|||
SDL_BlitSurface(bgrnd, NULL, surface, &drect ); |
|||
if(solved[countx][county] == 1) strcpy(buf,pl1); |
|||
if(solved[countx][county] == 2) strcpy(buf,pl2); |
|||
if(solved[countx][county] == 3) strcpy(buf,pl3); |
|||
|
|||
drect.x = (countx*200) + 65; |
|||
drect.y = drect.y + 23; |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
drect.w = text -> w; |
|||
drect.h = text -> h; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y - 23; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
for(countx=0;countx<=5;countx++) |
|||
{ |
|||
drect.x = (countx*200) + 65; |
|||
drect.y = 45; |
|||
strcpy(buf,mykat[countx].katname); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
} |
|||
|
|||
/* The Code for the Panle Drawing goes here */ |
|||
if(enp == TRUE){ |
|||
drect.w = panel -> w; |
|||
drect.h = panel -> h; |
|||
drect.x = 185; |
|||
drect.y = 100; |
|||
SDL_BlitSurface(panel, NULL, surface, &drect ); |
|||
drect.x = drect.x + 23; |
|||
drect.y = drect.y + 23; |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, "Antwort:" , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
strcpy(buf,myblock[xpos][ypos].frage); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
drect.y = drect.y - 23; |
|||
|
|||
drect.x = drect.x - 23; |
|||
drect.y = drect.y - 23; |
|||
} |
|||
|
|||
if(inp == TRUE){ |
|||
drect.w = panel -> w; |
|||
drect.h = panel -> h; |
|||
drect.x = 185; |
|||
drect.y = 100; |
|||
SDL_BlitSurface(panel, NULL, surface, &drect); |
|||
drect.x = drect.x + 23; |
|||
drect.y = drect.y + 23; |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, "Frage:" , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
strcpy(buf,myblock[xpos][ypos].antwort); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
drect.y = drect.y - 23; |
|||
|
|||
drect.x = drect.x - 23; |
|||
drect.y = drect.y - 23; |
|||
} |
|||
} |
|||
|
|||
/*Player gefuddel */ |
|||
|
|||
drect.y = (ypos*100) + 100; |
|||
drect.x = (xpos*200) + 65; |
|||
if(enp == FALSE && inp == FALSE){ |
|||
SDL_BlitSurface(afr,NULL,surface, &drect); |
|||
} |
|||
|
|||
drect.w = nfield -> h; |
|||
drect.h = nfield -> w; |
|||
drect.y = 650; |
|||
|
|||
for(countx=0;countx<=2;countx++) |
|||
{ |
|||
drect.x = (countx*365) + 50; |
|||
SDL_BlitSurface(nfield, NULL, surface, &drect ); |
|||
} |
|||
|
|||
drect.x = (plselect*365) + 50; |
|||
SDL_BlitSurface(plac,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl1,color); |
|||
drect.x = 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl2,color); |
|||
drect.x = (365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl3,color); |
|||
drect.x = (2*365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 30; |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[0]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[1]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = (365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[2]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = (2*365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_Flip(surface); |
|||
} |
|||
|
|||
|
|||
int main( int argc, char **argv ) |
|||
{ |
|||
/** \brief Zählt argc*/ |
|||
int option; |
|||
|
|||
/** \brief Flags zur Übergabe an den Video mode */ |
|||
int videoFlags; |
|||
|
|||
/** \brief Variable der Hauptschleife */ |
|||
int done = FALSE; |
|||
|
|||
/** \brief sammelt Events */ |
|||
SDL_Event event; |
|||
|
|||
/** \brief Display Informationen */ |
|||
const SDL_VideoInfo *videoInfo; |
|||
|
|||
/** \brief Ist unser Fenster Acti? */ |
|||
int isActive = TRUE; |
|||
|
|||
/** \brief String für den Fenstertitel */ |
|||
char *wmcapt ="SdlJPD " ; |
|||
|
|||
int audio_rate = 22050; |
|||
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ |
|||
int audio_channels = 2; |
|||
int audio_buffers = 4096; |
|||
|
|||
strcpy(pl1,"Dope Fish"); |
|||
strcpy(pl2,"Razor"); |
|||
strcpy(pl3,"Blade"); |
|||
|
|||
strcpy(xpfp,"level.txt"); |
|||
|
|||
while (( option = getopt(argc, argv, "hf:a:b:c:")) >= 0) |
|||
switch (option) |
|||
{ |
|||
case 'h': { |
|||
printf("Usage: %s [Optionen] \n Optionen: \n -h print this help Text \n-f <file> jeopardy file\n",argv[0]); |
|||
Quit(0); |
|||
} |
|||
break; |
|||
|
|||
case 'f': |
|||
strcpy(xpfp,optarg); |
|||
break; |
|||
|
|||
case 'a': |
|||
strcpy(pl1,optarg); |
|||
break; |
|||
|
|||
case 'b': |
|||
strcpy(pl2,optarg); |
|||
break; |
|||
|
|||
case 'c': |
|||
strcpy(pl3,optarg); |
|||
break; |
|||
} |
|||
|
|||
printf("\n \033[36m sdljpd -- jeopady on steroids \n Copyright (c) 2005 Frederick Bullik <Frederick.Bullik@gmx.de>\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software \n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\033[m \n\n"); |
|||
|
|||
printf("========================================================================\n"); |
|||
|
|||
/* if (iopl(3) != 0)
|
|||
{ |
|||
printf("\033[33m Hi, here is sdljpd:\033[31m I can't set I/O permissions, Sorry \033[m \n"); |
|||
return(1); |
|||
} |
|||
|
|||
if ((port_adr = get_lp_base()) == 0) |
|||
{ |
|||
printf("\033[33m sdljpd:\033[31m No parallel port found, Sorry \033[m \n"); |
|||
return(1); |
|||
} |
|||
|
|||
printf("\033[33m sdljpd: \033[32m Parrallel port found at 0x%x. \033[m \n", port_adr); |
|||
*/ |
|||
|
|||
filefoo(); |
|||
|
|||
if(TTF_Init()==-1) { |
|||
printf("TTF_Init: %s\n", TTF_GetError()); |
|||
exit(2); |
|||
} |
|||
|
|||
font=TTF_OpenFont("subfont.ttf", 26); |
|||
|
|||
if(!font) { |
|||
printf("TTF_OpenFont: %s\n", TTF_GetError()); |
|||
/* handle error*/ |
|||
} |
|||
|
|||
/* sprintf(wmcapt,"glpong - %s vs ", player_a );*/ |
|||
/* initialize SDL */ |
|||
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) |
|||
{ |
|||
fprintf( stderr, "Video initialization failed: %s\n", |
|||
SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { |
|||
printf("Unable to open audio!\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); |
|||
|
|||
/* Fetch the video info */ |
|||
videoInfo = SDL_GetVideoInfo( ); |
|||
|
|||
music_init(); |
|||
|
|||
if ( !videoInfo ) |
|||
{ |
|||
fprintf( stderr, "Video query failed: %s\n", |
|||
SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
SDL_WM_SetCaption(wmcapt, NULL); |
|||
/*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/ |
|||
|
|||
/* the flags to pass to SDL_SetVideoMode */ |
|||
videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ |
|||
videoFlags |= SDL_DOUBLEBUF; |
|||
videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ |
|||
videoFlags |= SDL_HWSURFACE; |
|||
videoFlags |= SDL_HWACCEL; |
|||
|
|||
SDL_ShowCursor( SDL_DISABLE); |
|||
|
|||
/* get a SDL surface */ |
|||
surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, |
|||
videoFlags ); |
|||
/* Verify there is a surface */ |
|||
if ( !surface ) |
|||
{ |
|||
fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
loadtex(); |
|||
|
|||
/* wait for events */ |
|||
while ( !done ) |
|||
{ |
|||
/* handle the events in the queue */ |
|||
|
|||
while ( SDL_PollEvent( &event ) ) |
|||
{ |
|||
switch( event.type ) |
|||
{ |
|||
|
|||
case SDL_ACTIVEEVENT: |
|||
/* Something's happend with our focus
|
|||
* If we lost focus or we are iconified, we |
|||
* shouldn't draw the screen |
|||
*/ |
|||
if ( event.active.gain == 0 ) |
|||
isActive = FALSE; |
|||
else |
|||
isActive = TRUE; |
|||
break; |
|||
|
|||
case SDL_VIDEORESIZE: |
|||
/* handle resize event */ |
|||
surface = SDL_SetVideoMode( event.resize.w, |
|||
event.resize.h, |
|||
16, videoFlags ); |
|||
if ( !surface ) |
|||
{ |
|||
fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
break; |
|||
|
|||
case SDL_KEYDOWN: |
|||
/* handle key presses */ |
|||
switch (event.key.keysym.sym){ |
|||
|
|||
case SDLK_ESCAPE: |
|||
Quit( 0 ); |
|||
break; |
|||
|
|||
case SDLK_q: |
|||
Quit( 0 ); |
|||
break; |
|||
|
|||
case SDLK_F1: |
|||
/* F1 key was pressed
|
|||
* this toggles fullscreen mode |
|||
*/ |
|||
SDL_WM_ToggleFullScreen( surface ); |
|||
break; |
|||
|
|||
case SDLK_a: |
|||
if(plselect >0){ |
|||
plselect --;} |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_d: |
|||
if(plselect <2){ |
|||
plselect ++;} |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_w: |
|||
score[plselect] = score[plselect] + 100; |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_s: |
|||
score[plselect] = score[plselect] - 100; |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_RETURN: |
|||
lockbz = FALSE; |
|||
enp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_LEFT: |
|||
if(enp == FALSE){ |
|||
if(xpos >0){ |
|||
xpos --; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_RIGHT: |
|||
if(enp == FALSE){ |
|||
if(xpos <4){ |
|||
xpos ++; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_UP: |
|||
if(enp == FALSE){ |
|||
if(ypos >0){ |
|||
ypos --; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_DOWN: |
|||
if(enp== FALSE) |
|||
{ |
|||
if(ypos <4){ |
|||
ypos ++; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_INSERT: |
|||
score[plselect]=score[plselect]+pkt[ypos]; |
|||
solved[xpos][ypos] = (plselect + 1); |
|||
lockbz = TRUE; |
|||
enp = FALSE; |
|||
inp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_DELETE: |
|||
score[plselect]=score[plselect]-pkt[ypos]; |
|||
lockbz = FALSE; |
|||
inp = FALSE; |
|||
enp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_PAGEUP: |
|||
solved[xpos][ypos] = (plselect + 1); |
|||
break; |
|||
|
|||
case SDLK_PAGEDOWN: |
|||
solved[xpos][ypos] = 0; |
|||
|
|||
case SDLK_l: |
|||
lockbz = TRUE; |
|||
break; |
|||
|
|||
case SDLK_u: |
|||
lockbz = FALSE; |
|||
break; |
|||
|
|||
case SDLK_r: |
|||
lockbz = FALSE; |
|||
inp = FALSE; |
|||
enp = FALSE; |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
break; |
|||
|
|||
case SDL_QUIT: |
|||
/* handle quit requests */ |
|||
done = TRUE; |
|||
break; |
|||
} |
|||
break; |
|||
} |
|||
draw_sdl(); |
|||
/*Mix_CloseAudio();*/ |
|||
} |
|||
|
|||
/* clean ourselves up and exit */ |
|||
Quit( 0 ); |
|||
|
|||
/* Should never get here */ |
|||
return( 0 ); |
|||
} |
|||
|
@ -0,0 +1,858 @@ |
|||
/***************************************************************************
|
|||
sdljpd.c - Jeopardy on steroids |
|||
------------------- |
|||
begin : So 15 Mai 2005 |
|||
copyright : (C) 2004 by Frederick Bullik |
|||
email : Frederick.Bullik@web.de |
|||
***************************************************************************/ |
|||
/***************************************************************************
|
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU General Public License as published by * |
|||
* the Free Software Foundation; either version 2 of the License, or * |
|||
* (at your option) any later version. * |
|||
* * |
|||
***************************************************************************/ |
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <unistd.h> /*include datei die das Komandozeilen handling vereinfacht*/ |
|||
#include <time.h> |
|||
#include <math.h> |
|||
#include <sys/io.h> |
|||
|
|||
#include "SDL.h" |
|||
#include "SDL_image.h" |
|||
#include "SDL_ttf.h" |
|||
#include "SDL_mixer.h" |
|||
|
|||
/* Define our booleans */ |
|||
#define TRUE 1 |
|||
#define FALSE 0 |
|||
|
|||
#define RENDER_MODE 2 //0=solid 1=shaded 2=blended
|
|||
|
|||
/* screen width, height, and bit depth */ |
|||
/** \brief Die Bildschirmbreite fuer den Fenstermodus */ |
|||
#define SCREEN_WIDTH 1024 |
|||
/** \brief Die Bildschirmhohe fuer den Fenstermodus */ |
|||
#define SCREEN_HEIGHT 768 |
|||
/** \brief Farbtiefe des Bildschirmes */ |
|||
#define SCREEN_BPP 24 |
|||
|
|||
/* make prototype of getopt because of "implicit declaration" */ |
|||
int getopt(int argc, char * const argv[], const char *optstring); |
|||
extern char *optarg; |
|||
extern int optind, opterr, optopt; |
|||
|
|||
char xpfp[1000]; |
|||
char buf[10000]; |
|||
char pl1[1000]; |
|||
char pl2[1000]; |
|||
char pl3[1000]; |
|||
char blub[1000]; |
|||
|
|||
int enp = FALSE; |
|||
int inp = FALSE; |
|||
signed int score[3] ={0,0,0}; |
|||
int scorebuf; |
|||
int plselect = 0; |
|||
int lockbz = FALSE; |
|||
int port_adr; |
|||
int xpos = 0, ypos = 0; |
|||
int solved[5][5] = {{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}, |
|||
{0,0,0,0,0}}; |
|||
int pkt[5] = {100,200,300,400,500}; |
|||
int artype; |
|||
int countxa = 0; |
|||
int countya = 0; |
|||
int countxf = 0; |
|||
int countyf = 0; |
|||
int countxt = 0; |
|||
|
|||
FILE *file; |
|||
|
|||
typedef struct s_block{ |
|||
char frage[10000]; |
|||
char antwort[1000]; |
|||
} t_block; |
|||
|
|||
typedef struct { |
|||
char katname[1000]; |
|||
} t_kat; |
|||
|
|||
t_block myblock[5][5]; |
|||
t_kat mykat[5]; |
|||
|
|||
Mix_Music *music = NULL; |
|||
|
|||
|
|||
/** \brief This is our SDL surface
|
|||
* |
|||
* Unser Haupt SDL Surface |
|||
*/ |
|||
SDL_Surface *surface; /*Display Surface*/ |
|||
SDL_Surface *kachel; /*hintergrund fuer die Fragefelder*/ |
|||
SDL_Surface *bgrnd; /*makriert blockierte Felder */ |
|||
SDL_Surface *nfield; /*Score, Namensfekder der Spieler*/ |
|||
SDL_Surface *plac; /*kenzeichnung acktiver Spierler*/ |
|||
SDL_Surface *afr; /*kenzeichnung des aktives fragen feldes */ |
|||
SDL_Surface *text; |
|||
SDL_Surface *panel; |
|||
|
|||
SDL_Rect drect; |
|||
|
|||
SDL_Color color={255,125,0}; |
|||
|
|||
TTF_Font *font; |
|||
|
|||
/** \brief Hier Raeumen wir nach Programablauf auf.
|
|||
* |
|||
* \param returnCode Der Zurueckzugebende Return Code |
|||
* \return Gibt den Uebergebenen Code aus |
|||
*/ |
|||
/* function to release/destroy our resources and restoring the old desktop */ |
|||
void Quit( int returnCode ) |
|||
{ |
|||
Mix_HaltMusic(); |
|||
Mix_FreeMusic(music); |
|||
music = NULL; |
|||
|
|||
SDL_FreeSurface(panel); |
|||
SDL_FreeSurface(text); |
|||
SDL_FreeSurface(afr); |
|||
SDL_FreeSurface(plac); |
|||
SDL_FreeSurface(nfield); |
|||
SDL_FreeSurface(kachel); |
|||
SDL_FreeSurface(bgrnd); |
|||
SDL_FreeSurface(surface); |
|||
|
|||
TTF_CloseFont(font); |
|||
|
|||
TTF_Quit(); |
|||
|
|||
/* clean up the window */ |
|||
SDL_Quit( ); |
|||
|
|||
/*fclose(file);*/ |
|||
|
|||
|
|||
printf("\033[33m sdljpd:\033[m So long, and thanks for all the fish <;))>< \n"); |
|||
|
|||
/* and exit appropriately */ |
|||
exit( returnCode ); |
|||
} |
|||
|
|||
void musicDone(void){ |
|||
Mix_HaltMusic(); |
|||
Mix_FreeMusic(music); |
|||
music = NULL; |
|||
music = Mix_LoadMUS("bgmusic-loop.wav"); |
|||
Mix_PlayMusic(music, -1); |
|||
} |
|||
|
|||
void music_init(void){ |
|||
if(music == NULL) { |
|||
music = Mix_LoadMUS("bgmusic-intro.wav"); |
|||
Mix_PlayMusic(music, 0); |
|||
Mix_HookMusicFinished(musicDone); |
|||
} |
|||
|
|||
} |
|||
|
|||
void filefill(void) |
|||
{ |
|||
|
|||
if(artype == 1) |
|||
{ |
|||
strcpy(mykat[countxt].katname,blub); |
|||
countxt ++; |
|||
blub[0] = '\0'; |
|||
|
|||
} |
|||
|
|||
if(artype == 2) |
|||
{ |
|||
strcpy(myblock[countxf][countyf].frage,blub); |
|||
countyf ++; |
|||
blub[0] = '\0'; |
|||
|
|||
if(countyf >4) |
|||
{ |
|||
countyf = 0; |
|||
countxf ++; |
|||
} |
|||
} |
|||
|
|||
if(artype == 3) |
|||
{ |
|||
strcpy(myblock[countxa][countya].antwort,blub); |
|||
countya ++; |
|||
blub[0] = '\0'; |
|||
|
|||
if(countya >4) |
|||
{ |
|||
countya = 0; |
|||
countxa ++; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
void filefoo (void) |
|||
{ |
|||
|
|||
char ch[100]; |
|||
char ach; |
|||
|
|||
file = fopen(xpfp,"r"); |
|||
|
|||
if(file == NULL) |
|||
{ |
|||
fprintf(stderr, "Folgende Datei konnte nicht geladen werden:%s\n",xpfp ); |
|||
} |
|||
|
|||
|
|||
while (fscanf(file,"%s",ch) ) |
|||
{ |
|||
|
|||
if (strcmp(ch,"Topic:") == 0){ |
|||
filefill(); |
|||
artype = 1; |
|||
continue; |
|||
} |
|||
|
|||
if (strcmp(ch,"Frage:")== 0){ |
|||
filefill(); |
|||
artype = 2; |
|||
continue; |
|||
} |
|||
|
|||
if (strcmp(ch,"Antwort:") == 0){ |
|||
filefill(); |
|||
artype = 3; |
|||
continue; |
|||
} |
|||
|
|||
strcat(blub, ch); |
|||
strcat(blub, " "); |
|||
|
|||
if (fscanf(file,"%c",&ach) == EOF){ |
|||
filefill(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
fclose(file); |
|||
|
|||
} |
|||
|
|||
|
|||
int get_lp_base(void) |
|||
{ |
|||
int i, base_adr[3] = {0x3bc, 0x378, 0x278}; |
|||
|
|||
for(i=0; i<3; i++) |
|||
{ |
|||
outb_p(0, base_adr[i]); |
|||
if (inb_p(base_adr[i]) == 0) |
|||
return(base_adr[i]); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
void loadtex( void ) |
|||
{ |
|||
kachel = IMG_Load("kachel100.jpg"); |
|||
|
|||
if (kachel == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
bgrnd = IMG_Load("bgrnd100.jpg"); |
|||
|
|||
if (bgrnd == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
nfield = IMG_Load("nfield.jpg"); |
|||
|
|||
if (nfield == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
|
|||
plac = IMG_Load("sp.jpg"); |
|||
|
|||
if (plac == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
afr = IMG_Load("aq.jpg"); |
|||
|
|||
if (afr == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
|
|||
panel = IMG_Load("panel1.jpg"); |
|||
|
|||
if (panel == NULL) |
|||
{ |
|||
fprintf(stderr, "Das Bild konnte nicht geladen werden:%s\n", SDL_GetError()); |
|||
exit(-1); |
|||
} |
|||
} |
|||
|
|||
/*void get_buz (void)
|
|||
{ |
|||
int status; |
|||
|
|||
if(lockbz == FALSE ) |
|||
{ |
|||
status = inb(port_adr + 1); |
|||
|
|||
if(status != 239) |
|||
{ |
|||
if(status == 207) |
|||
{ |
|||
plselect = 0; |
|||
lockbz = TRUE; |
|||
} |
|||
|
|||
if(status == 175) |
|||
{ |
|||
plselect = 1; |
|||
lockbz = TRUE; |
|||
} |
|||
|
|||
if(status == 111) |
|||
{ |
|||
plselect = 2; |
|||
lockbz = TRUE; |
|||
} |
|||
} |
|||
} |
|||
}*/ |
|||
|
|||
void draw_sdl (void) |
|||
{ |
|||
int countx =0; |
|||
int county =0; |
|||
|
|||
/* Spielfeld geschlumpfe*/ |
|||
drect.w = kachel -> w; |
|||
drect.h = kachel -> h; |
|||
|
|||
SDL_SetAlpha(bgrnd, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
SDL_SetAlpha(afr, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
SDL_SetAlpha(plac, SDL_SRCALPHA | SDL_RLEACCEL, 128); |
|||
|
|||
/*get_buz();*/ |
|||
|
|||
SDL_FillRect(surface, NULL, 0); |
|||
|
|||
for(county=0;county<=4;county++) |
|||
{ |
|||
drect.y = (county*100) + 100; |
|||
|
|||
for(countx=0;countx<=4;countx++) |
|||
{ |
|||
drect.x = (countx*200) + 65; |
|||
|
|||
SDL_BlitSurface(kachel, NULL, surface, &drect ); |
|||
|
|||
if(solved[countx][county] == 0){ |
|||
SDL_FreeSurface(text); |
|||
sprintf(buf,"%i",pkt[county]); |
|||
/*if(pkt[county]==100){buf = "100";}
|
|||
if(pkt[county]==200){buf = "200";} |
|||
if(pkt[county]==300){buf = "300";} |
|||
f(pkt[county]==400){buf = "400";} |
|||
if(pkt[county]==500){buf = "500";}*/ |
|||
text = TTF_RenderText_Blended(font, buf,color); |
|||
drect.x = drect.x + 23; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
} |
|||
|
|||
if(solved[countx][county] >=1){ |
|||
SDL_BlitSurface(bgrnd, NULL, surface, &drect ); |
|||
if(solved[countx][county] == 1) strcpy(buf,pl1); |
|||
if(solved[countx][county] == 2) strcpy(buf,pl2); |
|||
if(solved[countx][county] == 3) strcpy(buf,pl3); |
|||
|
|||
drect.x = (countx*200) + 65; |
|||
drect.y = drect.y + 23; |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
drect.w = text -> w; |
|||
drect.h = text -> h; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y - 23; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
for(countx=0;countx<=5;countx++) |
|||
{ |
|||
drect.x = (countx*200) + 65; |
|||
drect.y = 45; |
|||
strcpy(buf,mykat[countx].katname); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
} |
|||
|
|||
/* The Code for the Panle Drawing goes here */ |
|||
if(enp == TRUE){ |
|||
drect.w = panel -> w; |
|||
drect.h = panel -> h; |
|||
drect.x = 185; |
|||
drect.y = 100; |
|||
SDL_BlitSurface(panel, NULL, surface, &drect ); |
|||
drect.x = drect.x + 23; |
|||
drect.y = drect.y + 23; |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, "Antwort:" , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
strcpy(buf,myblock[xpos][ypos].frage); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
drect.y = drect.y - 23; |
|||
|
|||
drect.x = drect.x - 23; |
|||
drect.y = drect.y - 23; |
|||
} |
|||
|
|||
if(inp == TRUE){ |
|||
drect.w = panel -> w; |
|||
drect.h = panel -> h; |
|||
drect.x = 185; |
|||
drect.y = 100; |
|||
SDL_BlitSurface(panel, NULL, surface, &drect); |
|||
drect.x = drect.x + 23; |
|||
drect.y = drect.y + 23; |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, "Frage:" , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
strcpy(buf,myblock[xpos][ypos].antwort); |
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, buf , color); |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
drect.y = drect.y - 23; |
|||
|
|||
drect.x = drect.x - 23; |
|||
drect.y = drect.y - 23; |
|||
} |
|||
} |
|||
|
|||
/*Player gefuddel */ |
|||
|
|||
drect.y = (ypos*100) + 100; |
|||
drect.x = (xpos*200) + 65; |
|||
if(enp == FALSE && inp == FALSE){ |
|||
SDL_BlitSurface(afr,NULL,surface, &drect); |
|||
} |
|||
|
|||
drect.w = nfield -> h; |
|||
drect.h = nfield -> w; |
|||
drect.y = 650; |
|||
|
|||
for(countx=0;countx<=2;countx++) |
|||
{ |
|||
drect.x = (countx*365) + 50; |
|||
SDL_BlitSurface(nfield, NULL, surface, &drect ); |
|||
} |
|||
|
|||
drect.x = (plselect*365) + 50; |
|||
SDL_BlitSurface(plac,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 23; |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl1,color); |
|||
drect.x = 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl2,color); |
|||
drect.x = (365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
text = TTF_RenderText_Blended(font, pl3,color); |
|||
drect.x = (2*365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
drect.y = drect.y + 30; |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[0]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[1]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = (365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_FreeSurface(text); |
|||
scorebuf = score[2]; |
|||
sprintf(buf,"%i",scorebuf); |
|||
text = TTF_RenderText_Blended(font,buf,color); |
|||
drect.x = (2*365) + 65; |
|||
SDL_BlitSurface(text,NULL,surface,&drect); |
|||
|
|||
SDL_Flip(surface); |
|||
} |
|||
|
|||
|
|||
int main( int argc, char **argv ) |
|||
{ |
|||
/** \brief Zählt argc*/ |
|||
int option; |
|||
|
|||
/** \brief Flags zur Übergabe an den Video mode */ |
|||
int videoFlags; |
|||
|
|||
/** \brief Variable der Hauptschleife */ |
|||
int done = FALSE; |
|||
|
|||
/** \brief sammelt Events */ |
|||
SDL_Event event; |
|||
|
|||
/** \brief Display Informationen */ |
|||
const SDL_VideoInfo *videoInfo; |
|||
|
|||
/** \brief Ist unser Fenster Acti? */ |
|||
int isActive = TRUE; |
|||
|
|||
/** \brief String für den Fenstertitel */ |
|||
char *wmcapt ="SdlJPD " ; |
|||
|
|||
int audio_rate = 22050; |
|||
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ |
|||
int audio_channels = 2; |
|||
int audio_buffers = 4096; |
|||
|
|||
strcpy(pl1,"Dope Fish"); |
|||
strcpy(pl2,"Razor"); |
|||
strcpy(pl3,"Blade"); |
|||
|
|||
strcpy(xpfp,"level.txt"); |
|||
|
|||
while (( option = getopt(argc, argv, "hf:a:b:c:")) >= 0) |
|||
switch (option) |
|||
{ |
|||
case 'h': { |
|||
printf("Usage: %s [Optionen] \n Optionen: \n -h print this help Text \n-f <file> jeopardy file\n",argv[0]); |
|||
Quit(0); |
|||
} |
|||
break; |
|||
|
|||
case 'f': |
|||
strcpy(xpfp,optarg); |
|||
break; |
|||
|
|||
case 'a': |
|||
strcpy(pl1,optarg); |
|||
break; |
|||
|
|||
case 'b': |
|||
strcpy(pl2,optarg); |
|||
break; |
|||
|
|||
case 'c': |
|||
strcpy(pl3,optarg); |
|||
break; |
|||
} |
|||
|
|||
printf("\n \033[36m sdljpd -- jeopady on steroids \n Copyright (c) 2005 Frederick Bullik <Frederick.Bullik@gmx.de>\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software \n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\033[m \n\n"); |
|||
|
|||
printf("========================================================================\n"); |
|||
|
|||
/* if (iopl(3) != 0)
|
|||
{ |
|||
printf("\033[33m Hi, here is sdljpd:\033[31m I can't set I/O permissions, Sorry \033[m \n"); |
|||
return(1); |
|||
} |
|||
|
|||
if ((port_adr = get_lp_base()) == 0) |
|||
{ |
|||
printf("\033[33m sdljpd:\033[31m No parallel port found, Sorry \033[m \n"); |
|||
return(1); |
|||
} |
|||
|
|||
printf("\033[33m sdljpd: \033[32m Parrallel port found at 0x%x. \033[m \n", port_adr); |
|||
*/ |
|||
|
|||
filefoo(); |
|||
|
|||
if(TTF_Init()==-1) { |
|||
printf("TTF_Init: %s\n", TTF_GetError()); |
|||
exit(2); |
|||
} |
|||
|
|||
font=TTF_OpenFont("subfont.ttf", 26); |
|||
|
|||
if(!font) { |
|||
printf("TTF_OpenFont: %s\n", TTF_GetError()); |
|||
/* handle error*/ |
|||
} |
|||
|
|||
/* sprintf(wmcapt,"glpong - %s vs ", player_a );*/ |
|||
/* initialize SDL */ |
|||
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) |
|||
{ |
|||
fprintf( stderr, "Video initialization failed: %s\n", |
|||
SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { |
|||
printf("Unable to open audio!\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); |
|||
|
|||
/* Fetch the video info */ |
|||
videoInfo = SDL_GetVideoInfo( ); |
|||
|
|||
music_init(); |
|||
|
|||
if ( !videoInfo ) |
|||
{ |
|||
fprintf( stderr, "Video query failed: %s\n", |
|||
SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
SDL_WM_SetCaption(wmcapt, NULL); |
|||
/*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/ |
|||
|
|||
/* the flags to pass to SDL_SetVideoMode */ |
|||
videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ |
|||
videoFlags |= SDL_DOUBLEBUF; |
|||
videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ |
|||
videoFlags |= SDL_HWSURFACE; |
|||
videoFlags |= SDL_HWACCEL; |
|||
|
|||
SDL_ShowCursor( SDL_DISABLE); |
|||
|
|||
/* get a SDL surface */ |
|||
surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, |
|||
videoFlags ); |
|||
/* Verify there is a surface */ |
|||
if ( !surface ) |
|||
{ |
|||
fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
|
|||
loadtex(); |
|||
|
|||
/* wait for events */ |
|||
while ( !done ) |
|||
{ |
|||
/* handle the events in the queue */ |
|||
|
|||
while ( SDL_PollEvent( &event ) ) |
|||
{ |
|||
switch( event.type ) |
|||
{ |
|||
|
|||
case SDL_ACTIVEEVENT: |
|||
/* Something's happend with our focus
|
|||
* If we lost focus or we are iconified, we |
|||
* shouldn't draw the screen |
|||
*/ |
|||
if ( event.active.gain == 0 ) |
|||
isActive = FALSE; |
|||
else |
|||
isActive = TRUE; |
|||
break; |
|||
|
|||
case SDL_VIDEORESIZE: |
|||
/* handle resize event */ |
|||
surface = SDL_SetVideoMode( event.resize.w, |
|||
event.resize.h, |
|||
16, videoFlags ); |
|||
if ( !surface ) |
|||
{ |
|||
fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) ); |
|||
Quit( 1 ); |
|||
} |
|||
break; |
|||
|
|||
case SDL_KEYDOWN: |
|||
/* handle key presses */ |
|||
switch (event.key.keysym.sym){ |
|||
|
|||
case SDLK_ESCAPE: |
|||
Quit( 0 ); |
|||
break; |
|||
|
|||
case SDLK_q: |
|||
Quit( 0 ); |
|||
break; |
|||
|
|||
case SDLK_F1: |
|||
/* F1 key was pressed
|
|||
* this toggles fullscreen mode |
|||
*/ |
|||
SDL_WM_ToggleFullScreen( surface ); |
|||
break; |
|||
|
|||
case SDLK_a: |
|||
if(plselect >0){ |
|||
plselect --;} |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_d: |
|||
if(plselect <2){ |
|||
plselect ++;} |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_w: |
|||
score[plselect] = score[plselect] + 100; |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_s: |
|||
score[plselect] = score[plselect] - 100; |
|||
enp = FALSE; |
|||
inp = FALSE; |
|||
break; |
|||
|
|||
case SDLK_RETURN: |
|||
lockbz = FALSE; |
|||
enp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_LEFT: |
|||
if(enp == FALSE){ |
|||
if(xpos >0){ |
|||
xpos --; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_RIGHT: |
|||
if(enp == FALSE){ |
|||
if(xpos <4){ |
|||
xpos ++; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_UP: |
|||
if(enp == FALSE){ |
|||
if(ypos >0){ |
|||
ypos --; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_DOWN: |
|||
if(enp== FALSE) |
|||
{ |
|||
if(ypos <4){ |
|||
ypos ++; |
|||
} |
|||
inp = FALSE; |
|||
} |
|||
break; |
|||
|
|||
case SDLK_INSERT: |
|||
score[plselect]=score[plselect]+pkt[ypos]; |
|||
solved[xpos][ypos] = (plselect + 1); |
|||
lockbz = TRUE; |
|||
enp = FALSE; |
|||
inp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_DELETE: |
|||
score[plselect]=score[plselect]-pkt[ypos]; |
|||
lockbz = FALSE; |
|||
inp = FALSE; |
|||
enp = TRUE; |
|||
break; |
|||
|
|||
case SDLK_PAGEUP: |
|||
solved[xpos][ypos] = (plselect + 1); |
|||
break; |
|||
|
|||
case SDLK_PAGEDOWN: |
|||
solved[xpos][ypos] = 0; |
|||
|
|||
case SDLK_l: |
|||
lockbz = TRUE; |
|||
break; |
|||
|
|||
case SDLK_u: |
|||
lockbz = FALSE; |
|||
break; |
|||
|
|||
case SDLK_r: |
|||
lockbz = FALSE; |
|||
inp = FALSE; |
|||
enp = FALSE; |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
break; |
|||
|
|||
case SDL_QUIT: |
|||
/* handle quit requests */ |
|||
done = TRUE; |
|||
break; |
|||
} |
|||
break; |
|||
} |
|||
draw_sdl(); |
|||
/*Mix_CloseAudio();*/ |
|||
} |
|||
|
|||
/* clean ourselves up and exit */ |
|||
Quit( 0 ); |
|||
|
|||
/* Should never get here */ |
|||
return( 0 ); |
|||
} |
|||
|
After Width: | Height: | Size: 9.5 KiB |