h3ndrik
13 years ago
12 changed files with 16 additions and 1267 deletions
@ -1,9 +0,0 @@ |
|||||
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. |
|
@ -1,47 +0,0 @@ |
|||||
Topic: G-Phasen |
|
||||
Frage: Diese Fuenf sollen dem Gruppenleiter dabei helfen, Gruppenprozesse besser zu verstehen und seine eigene Arbeit besser reflektieren zu koennen |
|
||||
Antwort: Was sind die Gruppenphasen? |
|
||||
Frage: In dieser Phase muss man Kinder ihre eigene Rolle in der Gruppe finden lassen. Der Leiter muss auf Fairness achten |
|
||||
Antwort: Was ist die Machtkampfphase? |
|
||||
Frage: In dieser Phase muessen Aktionen gut vorbereitet werden und jeder muss ohne Hemmungen teilnehmen koennen. Ausserdem muss man einseitige Angebote vermeiden |
|
||||
Antwort: Was ist die Kennenlernphase / Orientierungsphase? |
|
||||
Frage: In dieser Phase koennen sich die Leiter etwas ausruhen und die Fruechte ihrer Arbeit geniessen. |
|
||||
Antwort: Was ist die Differenzierungsphase? |
|
||||
Frage: In dieser Phase kann man individuelle Faehigkeiten foerdern |
|
||||
Antwort: Was ist die Vertrautheitsphase? |
|
||||
|
|
||||
Topic: Gruppenstd |
|
||||
Frage: Sie sind ein unerschoepflicher Pool Ideen und Ueberlegungen |
|
||||
Antwort: Was sind Gruppenkinder? |
|
||||
Frage: Dieser Bogen bringt jeder Gruppenstunde einen Hoehepunkt |
|
||||
Antwort: Was ist der Spannungsbogen? |
|
||||
Frage: Diese Teile der regelmaessigen Aufgaben der Gruppenleiters machen ungefaehr gleich viel Zeit aus wie die Durchfuehrung der Gruppenstunden |
|
||||
Antwort: Was sind Reflexion und Planung? |
|
||||
Frage: Dieses Pfadfinderische Grundprinzip besagt, dass wir uns den Beduerfnissen der Kinder anpassen |
|
||||
Antwort: Was ist "Look at the boy/girl"? |
|
||||
Frage: Es ist die Grundlage fuer kreative und abwechslungsreiche Arbeit |
|
||||
Antwort: Was ist das Kennenlernen von neuen Ideen und Inhalten? |
|
||||
|
|
||||
Topic: Stil/Kultur |
|
||||
Frage: Hierbei suchen sich die Kinder gute Vorsaetze, die ihnen etwas Bedeuten |
|
||||
Antwort: Was ist das Versprechen? |
|
||||
Frage: Es ist der klare Anfang einer Gruppenstunde und kann helfen, Leute zu Puenktlichkeit anzuregen |
|
||||
Antwort: Was ist ein Einstiegsritual? |
|
||||
Frage: Dieses Spiel ist gut geeignet fuer das Ende einer Gruppenstunde |
|
||||
Antwort: ... |
|
||||
Frage: Sie ist das wichtigste Instrument pfadfinderischen Handelns, muss aber viel geuebt und praktiziert werden, um ihre Macht voll entfalten zu koennen |
|
||||
Antwort: Was ist Reflexion? |
|
||||
Frage: In einer kultivierten Gruppe sorgen diese dafuer, dass Diskussionen zielfuehrend und fruchtbar sind |
|
||||
Antwort: Was sind Diskussionsregeln und -methoden? |
|
||||
|
|
||||
Topic: Allgemeinw |
|
||||
Frage: Es ist die Bezeichnung für ein internationales Pfadfinder-Grosslager |
|
||||
Antwort: Was ist ein Jamboree? |
|
||||
Frage: So nennt man eine (Klein)gruppe aus 6-7 Kindern |
|
||||
Antwort: Was ist eine Sippe? |
|
||||
Frage: Dort ist das Bundeszentrum der DPSG |
|
||||
Antwort: Was ist in Westernohe? |
|
||||
Frage: So viele Seitenstangen braucht eine Jurte |
|
||||
Antwort: Was sind 12? |
|
||||
Frage: Das ist unsere Stammesnummer |
|
||||
Antwort: Was ist 10/07/10? |
|
@ -1,48 +0,0 @@ |
|||||
Topic: Konflikte |
|
||||
Frage: Eine Meinungsverschiedenheit, die z.B. durch unterschiedliche Werte und Ziele, unklare Strukturen oder Missverstaendnisse zustandekommt |
|
||||
Antwort: Was ist ein Konflikt? |
|
||||
Frage: Die Bereitschaft im Konflikt, sachlich und fair gegenueher dem Anderen zu bleiben |
|
||||
Antwort: Was ist Konfliktfaehigkeit? |
|
||||
Frage: Eine Vereinbarung, bei der alle Parteien von ihrer urspruenglichen Position abruecken |
|
||||
Antwort: Was ist ein Kompromiss? |
|
||||
Frage: Wer darin ist, sollte es sich eingestehen, und dem anderen entgegenkommen |
|
||||
Antwort: Was ist Unrecht |
|
||||
Frage: Es ist aus den Schriftzeichen fuer Gefahr und Chance zusammengesetzt |
|
||||
Antwort: Was ist das chinesische Zeichen fuer Krise? |
|
||||
|
|
||||
Topic: Motivation |
|
||||
Frage: Dieses Spiel foerdert Motivation der Gruppe |
|
||||
Antwort: ... |
|
||||
Frage: Mit diesem paedagogischen Grundprinzip gibt B.P. dem praktischen Lernen den Vorzug gegenueber dem theoretischen Lernen |
|
||||
Antwort: Was ist Learning by doing |
|
||||
Frage: Kann helfen, wenn die Luft raus ist, und macht aus einer guten Aktion eine hervorragende Aktion |
|
||||
Antwort: Was ist Animation? |
|
||||
Frage: Diese Form der Motivation nutzt sich schnell ab |
|
||||
Antwort: Was ist Belohnung? |
|
||||
Frage: Dies ist der Koenigsweg der Motivation |
|
||||
Antwort: Was ist Begeisterung? |
|
||||
|
|
||||
Topic: Partizipation |
|
||||
Frage: Dadurch werden Kinder z.B. bei einer Stammesversammlung zu muendigen Mit-Entscheidern und bleiben nicht bloss Stimmvieh |
|
||||
Antwort: Was ist Partizipation/Mitbestimmung? |
|
||||
Frage: Dieses Erziehungsprinzip von B.P. stellt die Eigenstaendigkeit der Kinder in den Vordergrund |
|
||||
Antwort: Was ist "Paddle your own canoe"? |
|
||||
Frage: Im Gegenzatz zum Rahmen, in der die Mitbestimmung stattfindet, entscheidet der Leiter hier nicht |
|
||||
Antwort: Was sind Inhalte/Thema? |
|
||||
Frage: Sie muss gehalten werden, damit Kinder weder ueberfordert, noch in ihrer Mitbestimmung gehindert werden |
|
||||
Antwort: Was ist Balance? |
|
||||
Frage: Diese Frage ueberfordert Kinder bei der Mitbestimmung. Sie ist selten zielfuehrend |
|
||||
Antwort: Was ist "Was wollt ihr denn machen?"? |
|
||||
|
|
||||
Topic: Geschichte |
|
||||
Frage: Es war die erste Jahresaktion der DPSG |
|
||||
Antwort: Was ist "Flinke Haende, flinke Fuesse"? |
|
||||
Frage: Der Kampf um diese Stadt machte BiPi zum Helden |
|
||||
Antwort: Was ist Mafeking (Suedafrika)? |
|
||||
Frage: Es ist ein Pfadfinderzentrum in der Naehe von London |
|
||||
Antwort: Was ist der Gilwell-Park? |
|
||||
Frage: Hier wurde die DPSG gegründet |
|
||||
Antwort: Was ist Altenberg? |
|
||||
Frage: Es ist der letzte Aufruf BiPis in seinem Abschiedsbrief |
|
||||
Antwort: Was ist "Versucht die Welt ein bisschen besser zurueckzulassen, als ihr sie vorgefunden habt."? |
|
||||
|
|
Binary file not shown.
@ -1,182 +0,0 @@ |
|||||
/*
|
|
||||
* Hidraw Userspace Example |
|
||||
* |
|
||||
* Copyright (c) 2010 Alan Ott <alan@signal11.us> |
|
||||
* Copyright (c) 2010 Signal 11 Software |
|
||||
* |
|
||||
* The code may be used by anyone for any purpose, |
|
||||
* and can serve as a starting point for developing |
|
||||
* applications using hidraw. |
|
||||
*/ |
|
||||
|
|
||||
/* Linux */ |
|
||||
#include <linux/types.h> |
|
||||
#include <linux/input.h> |
|
||||
#include <linux/hidraw.h> |
|
||||
|
|
||||
/*
|
|
||||
* Ugly hack to work around failing compilation on systems that don't |
|
||||
* yet populate new version of hidraw.h to userspace. |
|
||||
* |
|
||||
* If you need this, please have your distro update the kernel headers. |
|
||||
*/ |
|
||||
#ifndef HIDIOCSFEATURE |
|
||||
#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) |
|
||||
#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) |
|
||||
#endif |
|
||||
|
|
||||
/* Unix */ |
|
||||
#include <sys/ioctl.h> |
|
||||
#include <sys/types.h> |
|
||||
#include <sys/stat.h> |
|
||||
#include <fcntl.h> |
|
||||
#include <unistd.h> |
|
||||
|
|
||||
/* C */ |
|
||||
#include <stdio.h> |
|
||||
#include <string.h> |
|
||||
#include <stdlib.h> |
|
||||
#include <errno.h> |
|
||||
|
|
||||
const char *bus_str(int bus); |
|
||||
|
|
||||
int main(int argc, char **argv) |
|
||||
{ |
|
||||
int fd; |
|
||||
int i, res, desc_size = 0; |
|
||||
char buf[256]; |
|
||||
struct hidraw_report_descriptor rpt_desc; |
|
||||
struct hidraw_devinfo info; |
|
||||
|
|
||||
/* Open the Device with non-blocking reads. In real life,
|
|
||||
don't use a hard coded path; use libudev instead. */ |
|
||||
fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); |
|
||||
|
|
||||
if (fd < 0) { |
|
||||
perror("Unable to open device"); |
|
||||
return 1; |
|
||||
} |
|
||||
|
|
||||
memset(&rpt_desc, 0x0, sizeof(rpt_desc)); |
|
||||
memset(&info, 0x0, sizeof(info)); |
|
||||
memset(buf, 0x0, sizeof(buf)); |
|
||||
|
|
||||
/* Get Report Descriptor Size */ |
|
||||
res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size); |
|
||||
if (res < 0) |
|
||||
perror("HIDIOCGRDESCSIZE"); |
|
||||
else |
|
||||
printf("Report Descriptor Size: %d\n", desc_size); |
|
||||
|
|
||||
/* Get Report Descriptor */ |
|
||||
rpt_desc.size = desc_size; |
|
||||
res = ioctl(fd, HIDIOCGRDESC, &rpt_desc); |
|
||||
if (res < 0) { |
|
||||
perror("HIDIOCGRDESC"); |
|
||||
} else { |
|
||||
printf("Report Descriptor:\n"); |
|
||||
for (i = 0; i < rpt_desc.size; i++) |
|
||||
printf("%hhx ", rpt_desc.value[i]); |
|
||||
puts("\n"); |
|
||||
} |
|
||||
|
|
||||
/* Get Raw Name */ |
|
||||
res = ioctl(fd, HIDIOCGRAWNAME(256), buf); |
|
||||
if (res < 0) |
|
||||
perror("HIDIOCGRAWNAME"); |
|
||||
else |
|
||||
printf("Raw Name: %s\n", buf); |
|
||||
|
|
||||
/* Get Physical Location */ |
|
||||
res = ioctl(fd, HIDIOCGRAWPHYS(256), buf); |
|
||||
if (res < 0) |
|
||||
perror("HIDIOCGRAWPHYS"); |
|
||||
else |
|
||||
printf("Raw Phys: %s\n", buf); |
|
||||
|
|
||||
/* Get Raw Info */ |
|
||||
res = ioctl(fd, HIDIOCGRAWINFO, &info); |
|
||||
if (res < 0) { |
|
||||
perror("HIDIOCGRAWINFO"); |
|
||||
} else { |
|
||||
printf("Raw Info:\n"); |
|
||||
printf("\tbustype: %d (%s)\n", |
|
||||
info.bustype, bus_str(info.bustype)); |
|
||||
printf("\tvendor: 0x%04hx\n", info.vendor); |
|
||||
printf("\tproduct: 0x%04hx\n", info.product); |
|
||||
} |
|
||||
|
|
||||
/* Set Feature */ |
|
||||
// buf[0] = 0x9; /* Report Number */
|
|
||||
// buf[1] = 0xff;
|
|
||||
// buf[2] = 0xff;
|
|
||||
// buf[3] = 0xff;
|
|
||||
// res = ioctl(fd, HIDIOCSFEATURE(4), buf);
|
|
||||
// if (res < 0)
|
|
||||
// perror("HIDIOCSFEATURE");
|
|
||||
// else
|
|
||||
// printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
|
|
||||
|
|
||||
/* Get Feature */ |
|
||||
// buf[0] = 0x9; /* Report Number */
|
|
||||
// res = ioctl(fd, HIDIOCGFEATURE(256), buf);
|
|
||||
// if (res < 0) {
|
|
||||
// perror("HIDIOCGFEATURE");
|
|
||||
// } else {
|
|
||||
// printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
|
|
||||
// printf("Report data (not containing the report number):\n\t");
|
|
||||
// for (i = 0; i < res; i++)
|
|
||||
// printf("%hhx ", buf[i]);
|
|
||||
// puts("\n");
|
|
||||
// }
|
|
||||
|
|
||||
/* Send a Report to the Device */ |
|
||||
buf[0] = 0x0; /* Report Number */ |
|
||||
buf[1] = 0x00; |
|
||||
buf[2] = 0x01; |
|
||||
buf[3] = 0x00; |
|
||||
buf[4] = 0x00; |
|
||||
buf[5] = 0x01; |
|
||||
res = write(fd, buf, 6); |
|
||||
if (res < 0) { |
|
||||
printf("Error: %d\n", errno); |
|
||||
perror("write"); |
|
||||
} else { |
|
||||
printf("write() wrote %d bytes\n", res); |
|
||||
} |
|
||||
|
|
||||
/* Get a report from the device */ |
|
||||
res = read(fd, buf, 16); |
|
||||
if (res < 0) { |
|
||||
perror("read"); |
|
||||
} else { |
|
||||
printf("read() read %d bytes:\n\t", res); |
|
||||
for (i = 0; i < res; i++) |
|
||||
printf("%hhx ", buf[i]); |
|
||||
puts("\n"); |
|
||||
} |
|
||||
close(fd); |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
const char * |
|
||||
bus_str(int bus) |
|
||||
{ |
|
||||
switch (bus) { |
|
||||
case BUS_USB: |
|
||||
return "USB"; |
|
||||
break; |
|
||||
case BUS_HIL: |
|
||||
return "HIL"; |
|
||||
break; |
|
||||
case BUS_BLUETOOTH: |
|
||||
return "Bluetooth"; |
|
||||
break; |
|
||||
case BUS_VIRTUAL: |
|
||||
return "Virtual"; |
|
||||
break; |
|
||||
default: |
|
||||
return "Other"; |
|
||||
break; |
|
||||
} |
|
||||
} |
|
Binary file not shown.
@ -1,894 +0,0 @@ |
|||||
/***************************************************************************
|
|
||||
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" |
|
||||
#include "SDL_haptic.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 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; |
|
||||
|
|
||||
Mix_Music *buzz_sound = 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; |
|
||||
|
|
||||
SDL_Joystick *joystick; |
|
||||
|
|
||||
/** \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_JoystickClose(joystick); |
|
||||
|
|
||||
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); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
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 i,n; |
|
||||
|
|
||||
SDL_JoystickUpdate (); |
|
||||
|
|
||||
if(lockbz == FALSE ) |
|
||||
{ |
|
||||
for ( i=0; i < SDL_JoystickNumButtons ( joystick ); ++i ) |
|
||||
{ |
|
||||
n = SDL_JoystickGetButton ( joystick, i ); |
|
||||
if ( n != 0 ) { |
|
||||
printf ( "found you pressed button %i\n", i ); |
|
||||
if(i == 0) |
|
||||
{ |
|
||||
plselect = 0; |
|
||||
lockbz = TRUE; |
|
||||
Mix_PlayMusic(buzz_sound, 0); |
|
||||
} |
|
||||
|
|
||||
if(i == 5) |
|
||||
{ |
|
||||
plselect = 1; |
|
||||
lockbz = TRUE; |
|
||||
Mix_PlayMusic(buzz_sound, 0); |
|
||||
} |
|
||||
|
|
||||
if(i == 10) |
|
||||
{ |
|
||||
plselect = 2; |
|
||||
lockbz = TRUE; |
|
||||
Mix_PlayMusic(buzz_sound, 0); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
void draw_sdl (void) |
|
||||
{ |
|
||||
int countx =0; |
|
||||
int county =0; |
|
||||
|
|
||||
int i=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); |
|
||||
|
|
||||
for (i=0; i<=100; i++) |
|
||||
buf[i] = 0; |
|
||||
for (i=0; i<strlen(myblock[xpos][ypos].frage); i+=45) |
|
||||
{ |
|
||||
drect.y = drect.y + 23; |
|
||||
strncpy(buf,myblock[xpos][ypos].frage+i, 45); |
|
||||
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); |
|
||||
|
|
||||
for (i=0; i<=100; i++) |
|
||||
buf[i] = 0; |
|
||||
for (i=0; i<strlen(myblock[xpos][ypos].antwort); i+=45) |
|
||||
{ |
|
||||
drect.y = drect.y + 23; |
|
||||
strncpy(buf,myblock[xpos][ypos].antwort+i,45); |
|
||||
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,"Jessy"); |
|
||||
strcpy(pl2,"Micha"); |
|
||||
strcpy(pl3,"Pierre"); |
|
||||
|
|
||||
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"); |
|
||||
|
|
||||
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 | SDL_INIT_JOYSTICK) < 0 ) |
|
||||
{ |
|
||||
fprintf( stderr, "SDL 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(); |
|
||||
|
|
||||
buzz_sound = Mix_LoadMUS("buzzer.wav"); |
|
||||
|
|
||||
if ( !videoInfo ) |
|
||||
{ |
|
||||
fprintf( stderr, "Video query failed: %s\n", |
|
||||
SDL_GetError( ) ); |
|
||||
Quit( 1 ); |
|
||||
} |
|
||||
|
|
||||
printf ( "%i joysticks found: ", SDL_NumJoysticks () ); |
|
||||
|
|
||||
joystick = SDL_JoystickOpen (0); |
|
||||
if(joystick == NULL) { |
|
||||
printf("Unable to open joystick!\n"); |
|
||||
exit(1); |
|
||||
} |
|
||||
|
|
||||
SDL_JoystickEventState ( SDL_QUERY ); |
|
||||
|
|
||||
SDL_JoystickUpdate (); |
|
||||
|
|
||||
printf ( "%s\n", SDL_JoystickName ( 0 ) ); |
|
||||
|
|
||||
|
|
||||
SDL_Haptic *haptic; |
|
||||
haptic = SDL_HapticOpen( 0 ); |
|
||||
if (haptic == NULL) |
|
||||
return -1; |
|
||||
if (SDL_HapticRumbleInit( haptic ) != 0) |
|
||||
return -1; |
|
||||
if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) |
|
||||
return -1; |
|
||||
SDL_Delay( 2000 ); |
|
||||
SDL_HapticClose( haptic ); |
|
||||
|
|
||||
|
|
||||
|
|
||||
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; |
|
||||
|
|
||||
/* Player left */ |
|
||||
case SDLK_a: |
|
||||
if(plselect >0){ |
|
||||
plselect --;} |
|
||||
enp = FALSE; |
|
||||
inp = FALSE; |
|
||||
break; |
|
||||
|
|
||||
/* Player right */ |
|
||||
case SDLK_d: |
|
||||
if(plselect <2){ |
|
||||
plselect ++;} |
|
||||
enp = FALSE; |
|
||||
inp = FALSE; |
|
||||
break; |
|
||||
|
|
||||
/* Score Add 100 */ |
|
||||
case SDLK_w: |
|
||||
score[plselect] = score[plselect] + 100; |
|
||||
enp = FALSE; |
|
||||
inp = FALSE; |
|
||||
break; |
|
||||
|
|
||||
/* Score Subtract 100 */ |
|
||||
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; |
|
||||
|
|
||||
/* Right Answer */ |
|
||||
case SDLK_INSERT: |
|
||||
score[plselect]=score[plselect]+pkt[ypos]; |
|
||||
solved[xpos][ypos] = (plselect + 1); |
|
||||
lockbz = TRUE; |
|
||||
enp = FALSE; |
|
||||
inp = TRUE; |
|
||||
break; |
|
||||
|
|
||||
/* Wrong Answer */ |
|
||||
case SDLK_DELETE: |
|
||||
score[plselect]=score[plselect]-pkt[ypos]; |
|
||||
lockbz = FALSE; |
|
||||
inp = FALSE; |
|
||||
enp = TRUE; |
|
||||
break; |
|
||||
|
|
||||
/* Mark solved */ |
|
||||
case SDLK_PAGEUP: |
|
||||
solved[xpos][ypos] = (plselect + 1); |
|
||||
break; |
|
||||
|
|
||||
/* Mark unsolved */ |
|
||||
case SDLK_PAGEDOWN: |
|
||||
solved[xpos][ypos] = 0; |
|
||||
|
|
||||
/* Lock Buzzers */ |
|
||||
case SDLK_l: |
|
||||
lockbz = TRUE; |
|
||||
break; |
|
||||
|
|
||||
/* Unlock Buzzers */ |
|
||||
case SDLK_u: |
|
||||
lockbz = FALSE; |
|
||||
break; |
|
||||
|
|
||||
/* Reset playing field */ |
|
||||
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 ); |
|
||||
} |
|
||||
|
|
@ -1,67 +0,0 @@ |
|||||
#include <linux/types.h> |
|
||||
#include <linux/input.h> |
|
||||
#include <linux/hidraw.h> |
|
||||
#include <sys/ioctl.h> |
|
||||
#include <sys/types.h> |
|
||||
#include <sys/stat.h> |
|
||||
#include <fcntl.h> |
|
||||
#include <unistd.h> |
|
||||
#include <stdio.h> |
|
||||
#include <string.h> |
|
||||
#include <stdlib.h> |
|
||||
#include <errno.h> |
|
||||
|
|
||||
int main(int argc, char **argv) |
|
||||
{ |
|
||||
int fd; |
|
||||
int i, res = 0; |
|
||||
char buf[256]; |
|
||||
|
|
||||
/* Open the Device with non-blocking reads. In real life,
|
|
||||
don't use a hard coded path; use libudev instead. */ |
|
||||
fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); |
|
||||
|
|
||||
if (fd < 0) { |
|
||||
perror("Unable to open device"); |
|
||||
return 1; |
|
||||
} |
|
||||
|
|
||||
memset(buf, 0x0, sizeof(buf)); |
|
||||
|
|
||||
switch (argv[1][0]) { |
|
||||
case '0': |
|
||||
break; |
|
||||
case '1': |
|
||||
buf[2] = 0xff; |
|
||||
break; |
|
||||
case '2': |
|
||||
buf[3] = 0xff; |
|
||||
break; |
|
||||
case '3': |
|
||||
buf[4] = 0xff; |
|
||||
break; |
|
||||
case '4': |
|
||||
buf[5] = 0xff; |
|
||||
break; |
|
||||
default: |
|
||||
printf("Please specify 0 ... 4 as single argument.\n"); |
|
||||
} |
|
||||
|
|
||||
/* Send a Report to the Device */ |
|
||||
buf[0] = 0x00; /* Report Number */ |
|
||||
buf[1] = 0x00; /* Report ID */ |
|
||||
//buf[2] = 0x01; /* Buzzer 1 */
|
|
||||
//buf[3] = 0x00; /* Buzzer 2 */
|
|
||||
//buf[4] = 0x00; /* Buzzer 3 */
|
|
||||
//buf[5] = 0x01; /* Buzzer 4 */
|
|
||||
res = write(fd, buf, 6); |
|
||||
if (res < 0) { |
|
||||
printf("Error: %d\n", errno); |
|
||||
perror("write"); |
|
||||
} else { |
|
||||
//printf("write() wrote %d bytes\n", res);
|
|
||||
} |
|
||||
|
|
||||
close(fd); |
|
||||
return 0; |
|
||||
} |
|
@ -1,15 +0,0 @@ |
|||||
ESC, Q: Quit |
|
||||
F1: Fullscreen |
|
||||
A: Spieler links |
|
||||
D: Spieler rechts |
|
||||
W: Score+100 |
|
||||
S: Score-100 |
|
||||
RETURN: Frage anzeigen, Buzzer freigeben |
|
||||
Pfeiltasten: Frage auswählen |
|
||||
Insert: Gelöst, Antwort anzeigen, Punkte addieren |
|
||||
Delete: Buzzer freigeben, Punkte abziehen |
|
||||
PgUp: Gelöst (ohne Punkte) |
|
||||
PgDown: nicht Gelöst (ohne Punkte) |
|
||||
L: Lock. Buzzer sperren |
|
||||
U: Unlock. Buzzer freigeben |
|
||||
R: Reset. Spielfeld anzeigen, Buzzer freigeben |
|
Loading…
Reference in new issue