summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-01 21:30:00 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-01 21:30:00 +0000
commit8a14d60d2078b4bcdfc789b1b9794e2008979f02 (patch)
treea6095da867303ec71fed55a952ecd45fc0835417
parentf5258aed755575c1abf269348e4e335cdcb17a3b (diff)
- screen na vyberanie aren
- areny z povodnych tuxancov boli prescriptovane do tuxanci-ng, treba este dopisat teleporty a rury git-svn-id: http://opensvn.csie.org/tuxanci_ng@7 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
-rw-r--r--Makefile42
-rw-r--r--arena/Construction_site.map23
-rw-r--r--arena/In_a_captivity_of_8-bit.map19
-rw-r--r--arena/Night_workshift.map24
-rw-r--r--arena/for_a_good_night.map (renamed from arena/mapa1.map)8
-rw-r--r--image/construction_site.pngbin0 -> 69255 bytes
-rw-r--r--image/for_a_good_night.pngbin0 -> 69784 bytes
-rw-r--r--image/in_a_captivity_of_8-bit.pngbin0 -> 10085 bytes
-rw-r--r--image/l2.barel.pngbin0 -> 23817 bytes
-rw-r--r--image/l2.nadrz.pngbin0 -> 49503 bytes
-rw-r--r--image/l2.pitch.pngbin0 -> 789030 bytes
-rw-r--r--image/l2.potrubi.pngbin0 -> 47152 bytes
-rw-r--r--image/l2.retez.pngbin0 -> 41687 bytes
-rw-r--r--image/l2.trubky.pngbin0 -> 15349 bytes
-rw-r--r--image/l3.ihlan.pngbin0 -> 24543 bytes
-rw-r--r--image/l3.kvader1.pngbin0 -> 5458 bytes
-rw-r--r--image/l3.kvader2.pngbin0 -> 18573 bytes
-rw-r--r--image/l3.nic.pngbin0 -> 44575 bytes
-rw-r--r--image/l4.anim.blikacka.pngbin0 -> 4499 bytes
-rw-r--r--image/l4.bagr.pngbin0 -> 38796 bytes
-rw-r--r--image/l4.overlay.pngbin0 -> 69708 bytes
-rw-r--r--image/l4.palety.pngbin0 -> 30513 bytes
-rw-r--r--image/l4.pozadi.pngbin0 -> 773685 bytes
-rw-r--r--image/l4.pytle.pngbin0 -> 15128 bytes
-rw-r--r--image/l4.tvarnice.pngbin0 -> 8289 bytes
-rw-r--r--image/level4.pngbin0 -> 41126 bytes
-rw-r--r--image/night_workshift.pngbin0 -> 42982 bytes
-rw-r--r--include/arenaFile.h5
-rwxr-xr-xinclude/interface.h1
-rw-r--r--include/path.h18
-rw-r--r--include/screen_choiceArena.h15
-rw-r--r--include/screen_world.h2
-rw-r--r--include/widget_button.h2
-rw-r--r--include/widget_buttonimage.h25
-rw-r--r--music/for_a_good_night.ogg (renamed from music/noc.ogg)bin319720 -> 319720 bytes
-rw-r--r--music/in_a_captivity_of_8-bit.oggbin0 -> 129990 bytes
-rw-r--r--music/night_workshift.oggbin0 -> 119222 bytes
-rwxr-xr-xsrc/Makefile12
-rw-r--r--src/arenaFile.c66
-rwxr-xr-xsrc/interface.c4
-rw-r--r--src/main.c7
-rw-r--r--src/net_multiplayer.c23
-rw-r--r--src/screen_choiceArena.c165
-rw-r--r--src/screen_gameType.c9
-rw-r--r--src/screen_world.c46
-rw-r--r--src/widget_button.c8
-rw-r--r--src/widget_buttonimage.c54
47 files changed, 527 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 2b3c799..5fea5cf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,12 @@
-#DIST_DIR=/usr/local
-DIST_DIR=/usr
+#DISTDIR=/usr/local
+DISTDIR:=/usr/local/
all:
- make -C ./src
+ make -C ./src DISTDIR=$(DISTDIR)
clean:
- make -C ./src clean
+ make -C ./src DISTDIR=$(DISTDIR) clean
run:
./tuxanci-ng.sh
@@ -18,25 +18,25 @@ svnr:
svn co http://opensvn.csie.org/tuxanci_ng/
install:
- cp ./src/tuxanci-ng $(DIST_DIR)/bin/
- mkdir $(DIST_DIR)/share/tuxanci-ng
- mkdir $(DIST_DIR)/share/tuxanci-ng/arena
- mkdir $(DIST_DIR)/share/tuxanci-ng/font
- mkdir $(DIST_DIR)/share/tuxanci-ng/image
- mkdir $(DIST_DIR)/share/tuxanci-ng/lang
- mkdir $(DIST_DIR)/share/tuxanci-ng/music
- mkdir $(DIST_DIR)/share/tuxanci-ng/sound
-
- cp -rf ./arena/* $(DIST_DIR)/share/tuxanci-ng/arena
- cp -rf ./font/* $(DIST_DIR)/share/tuxanci-ng/font
- cp -rf ./image/* $(DIST_DIR)/share/tuxanci-ng/image
- cp -rf ./lang/* $(DIST_DIR)/share/tuxanci-ng/lang
- cp -rf ./music/* $(DIST_DIR)/share/tuxanci-ng/music
- cp -rf ./sound/* $(DIST_DIR)/share/tuxanci-ng/sound
+ cp ./src/tuxanci-ng $(DISTDIR)bin/
+ mkdir $(DISTDIR)share/tuxanci-ng
+ mkdir $(DISTDIR)share/tuxanci-ng/arena
+ mkdir $(DISTDIR)share/tuxanci-ng/font
+ mkdir $(DISTDIR)share/tuxanci-ng/image
+ mkdir $(DISTDIR)share/tuxanci-ng/lang
+ mkdir $(DISTDIR)share/tuxanci-ng/music
+ mkdir $(DISTDIR)share/tuxanci-ng/sound
+
+ cp -rf ./arena/* $(DISTDIR)share/tuxanci-ng/arena
+ cp -rf ./font/* $(DISTDIR)share/tuxanci-ng/font
+ cp -rf ./image/* $(DISTDIR)share/tuxanci-ng/image
+ cp -rf ./lang/* $(DISTDIR)share/tuxanci-ng/lang
+ cp -rf ./music/* $(DISTDIR)share/tuxanci-ng/music
+ cp -rf ./sound/* $(DISTDIR)share/tuxanci-ng/sound
deb:
./deb-build.sh
uninstall:
- rm -rf $(DIST_DIR)/bin/tuxanci-ng
- rm -rf $(DIST_DIR)/share/tuxanci-ng
+ rm -rf $(DISTDIR)bin/tuxanci-ng
+ rm -rf $(DISTDIR)share/tuxanci-ng
diff --git a/arena/Construction_site.map b/arena/Construction_site.map
new file mode 100644
index 0000000..a493526
--- /dev/null
+++ b/arena/Construction_site.map
@@ -0,0 +1,23 @@
+
+name construction site
+netName CS
+screen construction_site.png
+
+loadMusic file="night_workshift.ogg" name="night_workshift"
+
+loadImage file="l4.pozadi.png" name="pozadi" alpha="no"
+loadImage file="l4.bagr.png" name="bagr" alpha="yes"
+loadImage file="l4.pytle.png" name="pytle" alpha="yes"
+loadImage file="l4.tvarnice.png" name="tvarnice" alpha="yes"
+loadImage file="l4.palety.png" name="palety" alpha="yes"
+loadImage file="l4.overlay.png" name="overlay" alpha="yes"
+
+background image="pozadi"
+
+wall x="96" y="423" w="162" h="96" img_x="86" img_y="235" layer="0" image="bagr"
+wall x="425" y="358" w="120" h="55" img_x="410" img_y="326" layer="0" image="pytle"
+wall x="55" y="52" w="62" h="87" img_x="51" img_y="37" layer="0" image="tvarnice"
+wall x="92" y="0" w="198" h="118" img_x="65" img_y="0" layer="0" image="palety"
+wall x="0" y="0" w="0" h="0" img_x="0" img_y="0" layer="1" image="overlay"
+
+
diff --git a/arena/In_a_captivity_of_8-bit.map b/arena/In_a_captivity_of_8-bit.map
new file mode 100644
index 0000000..9e1dce4
--- /dev/null
+++ b/arena/In_a_captivity_of_8-bit.map
@@ -0,0 +1,19 @@
+
+name In a captivity of 8-bit
+netName IACO8B
+screen in_a_captivity_of_8-bit.png
+
+loadMusic file="in_a_captivity_of_8-bit.ogg" name="night_workshift"
+
+loadImage file="l3.nic.png" name="nic" alpha="no"
+loadImage file="l3.ihlan.png" name="ihlan" alpha="yes"
+loadImage file="l3.kvader1.png" name="kvader1" alpha="yes"
+loadImage file="l3.kvader2.png" name="kvader2" alpha="yes"
+
+background image="nic"
+
+playMusic music="in_a_captivity_of_8-bit"
+
+wall x="512" y="320" w="125" h="100" img_x="500" img_y="125" layer="0" image="ihlan"
+wall x="273" y="152" w="180" h="75" img_x="250" img_y="62" layer="0" image="kvader1"
+wall x="90" y="275" w="87" h="205" img_x="62" img_y="187" layer="0" image="kvader2"
diff --git a/arena/Night_workshift.map b/arena/Night_workshift.map
new file mode 100644
index 0000000..09d2623
--- /dev/null
+++ b/arena/Night_workshift.map
@@ -0,0 +1,24 @@
+
+name night workshift
+netName NW
+screen night_workshift.png
+
+loadMusic file="night_workshift.ogg" name="night_workshift"
+
+loadImage file="l2.pitch.png" name="pitch" alpha="no"
+loadImage file="l2.potrubi.png" name="potrubi" alpha="yes"
+loadImage file="l2.retez.png" name="retez" alpha="yes"
+loadImage file="l2.barel.png" name="barel" alpha="yes"
+loadImage file="l2.nadrz.png" name="nadrz" alpha="yes"
+loadImage file="l2.trubky.png" name="trubky" alpha="yes"
+
+background image="pitch"
+
+playMusic music="night_workshift"
+
+wall x="0" y="0" w="0" h="0" img_x="0" img_y="366" layer="1" image="potrubi"
+wall x="0" y="0" w="0" h="0" img_x="393" img_y="20" layer="1" image="retez"
+wall x="535" y="480" w="175" h="31" img_x="531" img_y="421" layer="0" image="barel"
+wall x="333" y="146" w="287" h="18" img_x="331" img_y="2" layer="0" image="nadrz"
+wall x="125" y="318" w="37" h="162" img_x="106" img_y="320" layer="0" image="trubky"
+
diff --git a/arena/mapa1.map b/arena/for_a_good_night.map
index 2ec49ee..b8387ff 100644
--- a/arena/mapa1.map
+++ b/arena/for_a_good_night.map
@@ -1,5 +1,9 @@
-loadMusic file="noc.ogg" name="noc"
+name For a good night
+netName FAGN
+screen for_a_good_night.png
+
+loadMusic file="for_a_good_night.ogg" name="for_a_good_night"
loadImage file="l1.grow.png" name="grow" alpha="no"
loadImage file="l1.hut.png" name="hut" alpha="yes"
@@ -9,7 +13,7 @@ loadImage file="l1.wood.png" name="wood" alpha="yes"
background image="grow"
-playMusic music="noc"
+playMusic music="for_a_good_night"
wall x="0" y="0" w="0" h="0" img_x="75" img_y="20" layer="1" image="hut"
wall x="120" y="159" w="180" h="65" img_x="90" img_y="159" layer="0" image="peduncle"
diff --git a/image/construction_site.png b/image/construction_site.png
new file mode 100644
index 0000000..c6aecc3
--- /dev/null
+++ b/image/construction_site.png
Binary files differ
diff --git a/image/for_a_good_night.png b/image/for_a_good_night.png
new file mode 100644
index 0000000..da8e981
--- /dev/null
+++ b/image/for_a_good_night.png
Binary files differ
diff --git a/image/in_a_captivity_of_8-bit.png b/image/in_a_captivity_of_8-bit.png
new file mode 100644
index 0000000..922786e
--- /dev/null
+++ b/image/in_a_captivity_of_8-bit.png
Binary files differ
diff --git a/image/l2.barel.png b/image/l2.barel.png
new file mode 100644
index 0000000..8da54ef
--- /dev/null
+++ b/image/l2.barel.png
Binary files differ
diff --git a/image/l2.nadrz.png b/image/l2.nadrz.png
new file mode 100644
index 0000000..4bc0a42
--- /dev/null
+++ b/image/l2.nadrz.png
Binary files differ
diff --git a/image/l2.pitch.png b/image/l2.pitch.png
new file mode 100644
index 0000000..15150ba
--- /dev/null
+++ b/image/l2.pitch.png
Binary files differ
diff --git a/image/l2.potrubi.png b/image/l2.potrubi.png
new file mode 100644
index 0000000..3afa5ff
--- /dev/null
+++ b/image/l2.potrubi.png
Binary files differ
diff --git a/image/l2.retez.png b/image/l2.retez.png
new file mode 100644
index 0000000..c97ea24
--- /dev/null
+++ b/image/l2.retez.png
Binary files differ
diff --git a/image/l2.trubky.png b/image/l2.trubky.png
new file mode 100644
index 0000000..5d405ad
--- /dev/null
+++ b/image/l2.trubky.png
Binary files differ
diff --git a/image/l3.ihlan.png b/image/l3.ihlan.png
new file mode 100644
index 0000000..20cb373
--- /dev/null
+++ b/image/l3.ihlan.png
Binary files differ
diff --git a/image/l3.kvader1.png b/image/l3.kvader1.png
new file mode 100644
index 0000000..67973a9
--- /dev/null
+++ b/image/l3.kvader1.png
Binary files differ
diff --git a/image/l3.kvader2.png b/image/l3.kvader2.png
new file mode 100644
index 0000000..d0df146
--- /dev/null
+++ b/image/l3.kvader2.png
Binary files differ
diff --git a/image/l3.nic.png b/image/l3.nic.png
new file mode 100644
index 0000000..3852007
--- /dev/null
+++ b/image/l3.nic.png
Binary files differ
diff --git a/image/l4.anim.blikacka.png b/image/l4.anim.blikacka.png
new file mode 100644
index 0000000..da353c6
--- /dev/null
+++ b/image/l4.anim.blikacka.png
Binary files differ
diff --git a/image/l4.bagr.png b/image/l4.bagr.png
new file mode 100644
index 0000000..a9f6a13
--- /dev/null
+++ b/image/l4.bagr.png
Binary files differ
diff --git a/image/l4.overlay.png b/image/l4.overlay.png
new file mode 100644
index 0000000..a8f8507
--- /dev/null
+++ b/image/l4.overlay.png
Binary files differ
diff --git a/image/l4.palety.png b/image/l4.palety.png
new file mode 100644
index 0000000..3a3e797
--- /dev/null
+++ b/image/l4.palety.png
Binary files differ
diff --git a/image/l4.pozadi.png b/image/l4.pozadi.png
new file mode 100644
index 0000000..9d9b214
--- /dev/null
+++ b/image/l4.pozadi.png
Binary files differ
diff --git a/image/l4.pytle.png b/image/l4.pytle.png
new file mode 100644
index 0000000..ea6a1f3
--- /dev/null
+++ b/image/l4.pytle.png
Binary files differ
diff --git a/image/l4.tvarnice.png b/image/l4.tvarnice.png
new file mode 100644
index 0000000..0f2d99a
--- /dev/null
+++ b/image/l4.tvarnice.png
Binary files differ
diff --git a/image/level4.png b/image/level4.png
new file mode 100644
index 0000000..0136b2b
--- /dev/null
+++ b/image/level4.png
Binary files differ
diff --git a/image/night_workshift.png b/image/night_workshift.png
new file mode 100644
index 0000000..08f4c42
--- /dev/null
+++ b/image/night_workshift.png
Binary files differ
diff --git a/include/arenaFile.h b/include/arenaFile.h
index 47d9586..f838c6a 100644
--- a/include/arenaFile.h
+++ b/include/arenaFile.h
@@ -8,6 +8,11 @@
extern bool_t isArenaFileInicialized();
extern void initArenaFile();
+extern int getArenaCount();
+extern char *getArenaName(int id);
+extern char *getArenaNetName(int id);
+extern int getArenaIdFormNetName(char *s);
+extern char *getArenaImage(int id);
extern arena_t* getArena(int id);
extern void quitArenaFile();
diff --git a/include/interface.h b/include/interface.h
index 3335ff1..858f295 100755
--- a/include/interface.h
+++ b/include/interface.h
@@ -35,6 +35,7 @@ extern int initSDL();
extern SDL_Surface* getSDL_Screen();
extern void getMousePosition(int *x, int *y);
extern int isMouseClicked();
+extern void interfaceRefresh();
extern void eventSDL();
extern void quitSDL();
diff --git a/include/path.h b/include/path.h
index b48e3d4..11eeaee 100644
--- a/include/path.h
+++ b/include/path.h
@@ -3,16 +3,14 @@
#define PATH_H
-//#define PATH_DIST_DIR "/usr/local/share/tuxanci-ng/"
+#define PATH_DIR "share/tuxanci-ng/"
-#define PATH_DIST_DIR "/usr/share/tuxanci-ng/"
-
-#define PATH_IMAGE PATH_DIST_DIR "image/"
-#define PATH_FONT PATH_DIST_DIR "font/"
-#define PATH_ARENA PATH_DIST_DIR "arena/"
-#define PATH_SOUND PATH_DIST_DIR "sound/"
-#define PATH_MUSIC PATH_DIST_DIR "music/"
-#define PATH_CONFIG PATH_DIST_DIR "conf/"
-#define PATH_LANG PATH_DIST_DIR "lang/"
+#define PATH_IMAGE DISTDIR PATH_DIR "image/"
+#define PATH_FONT DISTDIR PATH_DIR "font/"
+#define PATH_ARENA DISTDIR PATH_DIR "arena/"
+#define PATH_SOUND DISTDIR PATH_DIR "sound/"
+#define PATH_MUSIC DISTDIR PATH_DIR "music/"
+#define PATH_CONFIG DISTDIR PATH_DIR "conf/"
+#define PATH_LANG DISTDIR PATH_DIR "lang/"
#endif
diff --git a/include/screen_choiceArena.h b/include/screen_choiceArena.h
new file mode 100644
index 0000000..0b10006
--- /dev/null
+++ b/include/screen_choiceArena.h
@@ -0,0 +1,15 @@
+
+#ifndef SCREEN_CHOICE_ARENA
+
+#define SCREEN_GAME_TYPE
+
+#define SCREENSHOT_ARENA_WIDTH 160
+#define SCREENSHOT_ARENA_HEIGHT 107
+
+extern void drawScreenChoiceArena();
+extern void eventScreenChoiceArena();
+extern int getChoiceArenaId();
+extern void initScreenChoiceArena();
+extern void quitScreenChoiceArena();
+
+#endif
diff --git a/include/screen_world.h b/include/screen_world.h
index 937e0a2..aa43968 100644
--- a/include/screen_world.h
+++ b/include/screen_world.h
@@ -12,7 +12,9 @@
extern bool_t isScreenWorldInicialized();
extern void initWorld();
extern arena_t* getWorldArena();
+extern void setWorldArena(int id);
extern void countRoundInc();
+extern void setMaxCountRound(int n);
extern int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2);
extern int isFreeSpace(int x, int y, int w, int h);
extern void findFreeSpace(int *x, int *y, int w, int h);
diff --git a/include/widget_button.h b/include/widget_button.h
index 5fbcfb2..0787878 100644
--- a/include/widget_button.h
+++ b/include/widget_button.h
@@ -3,6 +3,8 @@
#define WIDGET_BUTTON_H
+#define WIDGET_BUTTON_TIME 10
+
#define WIDGET_BUTTON_WIDTH 125
#define WIDGET_BUTTON_HEIGHT 36
diff --git a/include/widget_buttonimage.h b/include/widget_buttonimage.h
new file mode 100644
index 0000000..8b279ce
--- /dev/null
+++ b/include/widget_buttonimage.h
@@ -0,0 +1,25 @@
+
+#ifndef WIDGET_BUTTONIMAGE_H
+
+#define WIDGET_BUTTONIMAGE_H
+
+#define WIDGET_BUTTONIMAGE_TIME 10
+
+typedef struct widget_buttonimageimage
+{
+ int x, y;
+ int w, h;
+ int active;
+ SDL_Surface *image;
+ void (*fce_event)(void *);
+} widget_buttonimage_t;
+
+extern widget_buttonimage_t* newWidgetButtonimage(SDL_Surface *image, int x, int y,
+ void (*fce_event)(void *));
+
+extern void drawWidgetButtonimage(widget_buttonimage_t *p);
+extern void eventWidgetButtonimage(widget_buttonimage_t *p);
+extern void destroyWidgetButtonimage(widget_buttonimage_t *p);
+
+#endif
+
diff --git a/music/noc.ogg b/music/for_a_good_night.ogg
index 3ce2996..3ce2996 100644
--- a/music/noc.ogg
+++ b/music/for_a_good_night.ogg
Binary files differ
diff --git a/music/in_a_captivity_of_8-bit.ogg b/music/in_a_captivity_of_8-bit.ogg
new file mode 100644
index 0000000..db8ee5c
--- /dev/null
+++ b/music/in_a_captivity_of_8-bit.ogg
Binary files differ
diff --git a/music/night_workshift.ogg b/music/night_workshift.ogg
new file mode 100644
index 0000000..c5ce5fc
--- /dev/null
+++ b/music/night_workshift.ogg
Binary files differ
diff --git a/src/Makefile b/src/Makefile
index 224e70a..31f3393 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,14 +1,15 @@
CC = gcc
-CFLAGS = -g -O0 `sdl-config --cflags` -I../include -Wall
+CFLAGS = -g -O0 -DDISTDIR=\"$(DISTDIR)\" `sdl-config --cflags` -I../include -Wall
LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer
FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o main.o \
screen.o screen_world.o wall.o shot.o myTimer.o panel.o net_multiplayer.o network.o \
buffer.o dynamicInt.o arena.o arenaFile.o textFile.o sound.o audio.o music.o gun.o \
item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \
- widget_check.o widget_image.o screen_setting.o screen_gameType.o
+ widget_check.o widget_image.o screen_setting.o screen_gameType.o screen_choiceArena.o \
+ widget_buttonimage.o
tuxanci-ng: $(FILES)
@@ -107,12 +108,18 @@ screen_setting.o: screen_setting.c ../include/screen_setting.h
screen_gameType.o: screen_gameType.c ../include/screen_gameType.h
$(CC) $(CFLAGS) -o screen_gameType.o -c screen_gameType.c
+screen_choiceArena.o: screen_choiceArena.c ../include/screen_choiceArena.h
+ $(CC) $(CFLAGS) -o screen_choiceArena.o -c screen_choiceArena.c
+
widget_label.o: widget_label.c ../include/widget_label.h
$(CC) $(CFLAGS) -o widget_label.o -c widget_label.c
widget_button.o: widget_button.c ../include/widget_button.h
$(CC) $(CFLAGS) -o widget_button.o -c widget_button.c
+widget_buttonimage.o: widget_buttonimage.c ../include/widget_buttonimage.h
+ $(CC) $(CFLAGS) -o widget_buttonimage.o -c widget_buttonimage.c
+
widget_textfield.o: widget_textfield.c ../include/widget_textfield.h
$(CC) $(CFLAGS) -o widget_textfield.o -c widget_textfield.c
@@ -122,5 +129,6 @@ widget_check.o: widget_check.c ../include/widget_check.h
widget_image.o: widget_image.c ../include/widget_image.h
$(CC) $(CFLAGS) -o widget_image.o -c widget_image.c
+
clean:
rm -rf *.o *.c~ *.h~ tuxanci-ng
diff --git a/src/arenaFile.c b/src/arenaFile.c
index 34b3335..e1cc5b4 100644
--- a/src/arenaFile.c
+++ b/src/arenaFile.c
@@ -140,6 +140,72 @@ static void cmd_wall(arena_t *arena, char *line)
addList(arena->listWall, new);
}
+int getArenaCount()
+{
+ return listArenaFile->count;
+}
+
+static char *getArenaStatus(int id, char *s)
+{
+ textFile_t *ts;
+ int len;
+ int i;
+
+ ts = (textFile_t *) listArenaFile->list[id];
+ len = strlen(s);
+
+ for( i = 0 ; i < ts->text->count ; i++ )
+ {
+ char *line;
+ line = (char *) (ts->text->list[i]);
+
+ if( strncmp(line, s, len) == 0 )
+ {
+ return line+len+1;
+ }
+ }
+
+ return NULL;
+}
+
+char *getArenaName(int id)
+{
+ char *ret;
+
+ ret = getArenaStatus(id, "name");
+
+ return ( ret != NULL ? ret : "arena_no_name" );
+}
+
+char *getArenaNetName(int id)
+{
+ char *ret;
+
+ ret = getArenaStatus(id, "netName");
+
+ return ( ret != NULL ? ret : "arena_no_net_name" );
+}
+
+int getArenaIdFormNetName(char *s)
+{
+ int i;
+
+ for( i = 0 ; i < listArenaFile->count ; i++ )
+ {
+ if( strcmp(getArenaNetName(i), s) == 0 )
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+char *getArenaImage(int id)
+{
+ return getArenaStatus(id, "screen");
+}
+
arena_t* getArena(int id)
{
textFile_t *ts;
diff --git a/src/interface.c b/src/interface.c
index 42ced59..fbc6dea 100755
--- a/src/interface.c
+++ b/src/interface.c
@@ -81,8 +81,8 @@ SDL_Surface* getSDL_Screen()
void interfaceRefresh()
{
//SDL_BlitSurface(fake_screen, NULL, screen, NULL);
- SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
- //SDL_Flip(screen);
+ //SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
+ SDL_Flip(screen);
}
int toggleFullscreen()
diff --git a/src/main.c b/src/main.c
index e6fb709..dad0ea4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,6 +13,7 @@
#include "screen_analyze.h"
#include "screen_setting.h"
#include "screen_gameType.h"
+#include "screen_choiceArena.h"
#include "wall.h"
#include "shot.h"
#include "panel.h"
@@ -46,6 +47,7 @@ static void init()
initScreenAnalyze();
initScreenSetting();
initScreenGameType();
+ initScreenChoiceArena();
}
void quit()
@@ -68,6 +70,9 @@ void quit()
quitScreenAnalyze();
quitScreenSetting();
quitScreenGameType();
+ quitScreenChoiceArena();
+
+ printf("quit..\n");
exit(0);
}
@@ -126,6 +131,8 @@ int main(int argc, char *argv[])
{
srand( (unsigned) time(NULL) );
+ printf("dist dir = %s\n", DISTDIR);
+
my_argc = argc;
my_argv = argv;
diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c
index 9080d26..786e1b9 100644
--- a/src/net_multiplayer.c
+++ b/src/net_multiplayer.c
@@ -14,6 +14,8 @@
#include "screen.h"
#include "screen_world.h"
#include "screen_setting.h"
+#include "screen_choiceArena.h"
+#include "arenaFile.h"
#include "net_multiplayer.h"
static int netGameType;
@@ -160,9 +162,13 @@ static void destroyClient(client_t *p)
void proto_send_init_server(client_t *client)
{
char msg[STR_SIZE];
+ int n;
- sprintf(msg, "init %d %d %d\n",
- client->tux->id, client->tux->x, client->tux->y);
+ getSettingCountRound(&n);
+
+ sprintf(msg, "init %d %d %d %d %s\n",
+ client->tux->id, client->tux->x, client->tux->y,
+ n, getArenaNetName( getChoiceArenaId() ));
sendClient(client, msg);
}
@@ -170,15 +176,22 @@ void proto_send_init_server(client_t *client)
void proto_recv_init_client(char *msg)
{
char cmd[STR_SIZE];
+ char arena_name[STR_SIZE];
tux_t *tux;
+ int id;
+ int n;
- tux = newTux();
+ sscanf(msg, "%s %d %d %d %d %s\n",
+ cmd, &id, &tux->x, &tux->y, &n, arena_name);
- sscanf(msg, "%s %d %d %d\n",
- cmd, &tux->id, &tux->x, &tux->y);
+ setWorldArena( getArenaIdFormNetName(arena_name) );
+ setMaxCountRound(n);
+ tux = newTux();
+ tux->id = id;
tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
getSettingNameRight(tux->name);
+
proto_send_context_client(tux);
addList(arena->listTux, tux);
}
diff --git a/src/screen_choiceArena.c b/src/screen_choiceArena.c
new file mode 100644
index 0000000..c3637f1
--- /dev/null
+++ b/src/screen_choiceArena.c
@@ -0,0 +1,165 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "main.h"
+#include "interface.h"
+#include "list.h"
+#include "screen.h"
+#include "image.h"
+#include "music.h"
+#include "arenaFile.h"
+#include "screen_mainMenu.h"
+#include "screen_choiceArena.h"
+
+#include "widget_label.h"
+#include "widget_button.h"
+#include "widget_image.h"
+#include "widget_buttonimage.h"
+
+static widget_image_t *image_backgorund;
+
+static widget_button_t *button_play;
+static widget_button_t *button_back;
+
+static list_t *listWidgetButtonimage;
+static int choiceArenaId;
+
+void startScreenChoiceArena()
+{
+ playMusic("menu", MUSIC_GROUP_BASE);
+}
+
+void drawScreenChoiceArena()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+ this = (widget_buttonimage_t *) listWidgetButtonimage->list[i];
+ drawWidgetButtonimage(this);
+ }
+}
+
+void eventScreenChoiceArena()
+{
+ int i;
+
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+ this = (widget_buttonimage_t *) listWidgetButtonimage->list[i];
+ eventWidgetButtonimage(this);
+ }
+}
+
+void stopScreenChoiceArena()
+{
+}
+
+static void eventWidgetButtonImage(void *p)
+{
+ widget_buttonimage_t *buttonimage;
+ int i;
+
+ buttonimage = (widget_buttonimage_t *)(p);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+
+ this = (widget_buttonimage_t *)(listWidgetButtonimage->list[i]);
+
+ if( buttonimage == this )
+ {
+ this->active = 1;
+ choiceArenaId = i;
+ }
+ else
+ {
+ this->active = 0;
+ }
+ }
+}
+
+int getChoiceArenaId()
+{
+ return choiceArenaId;
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_play )
+ {
+ setScreen("world");
+ }
+
+ if( button == button_back )
+ {
+ setScreen("gameType");
+ }
+}
+
+void initScreenChoiceArena()
+{
+ SDL_Surface *image;
+ int i;
+
+ image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton("Back", 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton("Play", WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+
+ addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
+
+ registerScreen( newScreen("chiceArena", startScreenChoiceArena, eventScreenChoiceArena,
+ drawScreenChoiceArena, stopScreenChoiceArena) );
+
+ listWidgetButtonimage = newList();
+ choiceArenaId = 0;
+
+ for( i = 0 ; i < getArenaCount() ; i++ )
+ {
+ SDL_Surface *image;
+ widget_buttonimage_t *widget_buttonimage;
+ int x, y;
+
+ image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
+
+ x = 100 + 200 * ( i - 3 * ( i/3 ) );
+ y = 150 + 200*(i/3);
+
+ widget_buttonimage = newWidgetButtonimage(image,
+ x, y, eventWidgetButtonImage);
+
+ if( i == choiceArenaId )
+ {
+ widget_buttonimage->active = 1;
+ }
+
+ addList( listWidgetButtonimage, widget_buttonimage);
+ }
+}
+
+void quitScreenChoiceArena()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_back);
+}
+
diff --git a/src/screen_gameType.c b/src/screen_gameType.c
index 6a04da6..cde03a3 100644
--- a/src/screen_gameType.c
+++ b/src/screen_gameType.c
@@ -129,7 +129,14 @@ static void eventWidget(void *p)
if( button == button_play )
{
- setScreen("world");
+ if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
+ {
+ setScreen("world");
+ }
+ else
+ {
+ setScreen("chiceArena");
+ }
}
}
diff --git a/src/screen_world.c b/src/screen_world.c
index 8d0b87d..1f91cc6 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -10,6 +10,7 @@
#include "screen_analyze.h"
#include "screen_setting.h"
#include "screen_gameType.h"
+#include "screen_choiceArena.h"
#include "list.h"
#include "layer.h"
@@ -38,7 +39,7 @@ bool_t isScreenWorldInicialized()
return isScreenWorldInit;
}
-static void setGameType()
+void setGameType()
{
if( getSettingGameType() == NET_GAME_TYPE_SERVER )
{
@@ -56,6 +57,17 @@ arena_t* getWorldArena()
return arena;
}
+void setWorldArena(int id)
+{
+ arena = getArena(id);
+ netSetArena(arena);
+}
+
+void setMaxCountRound(int n)
+{
+ max_count = n;
+}
+
static void timer_endArena()
{
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
@@ -99,13 +111,18 @@ static tux_t* getControlTux(int control_type)
return NULL;
}
-void createTux()
+void prepareArena()
{
tux_t *tux;
switch( getNetTypeGame() )
{
case NET_GAME_TYPE_NONE :
+ setWorldArena( getChoiceArenaId() );
+ addNewItem(arena->listItem);
+ playMusic(arena->music, MUSIC_GROUP_USER);
+ getSettingCountRound(&max_count);
+
tux = newTux();
tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
getSettingNameRight(tux->name);
@@ -118,6 +135,11 @@ void createTux()
break;
case NET_GAME_TYPE_SERVER :
+ setWorldArena( getChoiceArenaId() );
+ addNewItem(arena->listItem);
+ playMusic(arena->music, MUSIC_GROUP_USER);
+ getSettingCountRound(&max_count);
+
tux = newTux();
tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
getSettingNameRight(tux->name);
@@ -133,6 +155,11 @@ void drawWorld()
{
tux_t *tux = NULL;
+ if( arena == NULL )
+ {
+ return;
+ }
+
addLayer(arena->background, 0, 0, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, -100);
drawListTux(arena->listTux);
@@ -306,6 +333,12 @@ void tuxControl(tux_t *p)
void eventWorld()
{
+ if( arena == NULL )
+ {
+ eventNetMultiplayer();
+ return;
+ }
+
eventListTux(arena->listTux);
eventConflictShotWithTux(arena->listTux, arena->listShot);
@@ -322,15 +355,12 @@ void eventWorld()
void startWorld()
{
- arena = getArena(0);
+ arena = NULL;
+
count = 0;
- getSettingCountRound(&max_count);
- netSetArena(arena);
setGameType();
- createTux();
- addNewItem(arena->listItem);
- playMusic(arena->music, MUSIC_GROUP_USER);
+ prepareArena();
initTimer();
}
diff --git a/src/widget_button.c b/src/widget_button.c
index 940b7bd..1024091 100644
--- a/src/widget_button.c
+++ b/src/widget_button.c
@@ -52,14 +52,22 @@ void drawWidgetButton(widget_button_t *p)
void eventWidgetButton(widget_button_t *p)
{
+ static int time = 0;
int x, y;
+ if( time > 0)
+ {
+ time--;
+ return;
+ }
+
getMousePosition(&x, &y);
if( x >= p->x && x <= p->x+WIDGET_BUTTON_WIDTH &&
y >= p->y && y <= p->y+WIDGET_BUTTON_HEIGHT &&
isMouseClicked() )
{
+ time = WIDGET_BUTTON_TIME;
p->fce_event(p);
}
}
diff --git a/src/widget_buttonimage.c b/src/widget_buttonimage.c
new file mode 100644
index 0000000..0b1cb97
--- /dev/null
+++ b/src/widget_buttonimage.c
@@ -0,0 +1,54 @@
+
+#include "main.h"
+#include "interface.h"
+#include "font.h"
+#include "widget_buttonimage.h"
+#include "image.h"
+
+widget_buttonimage_t* newWidgetButtonimage(SDL_Surface *image, int x, int y, void (*fce_event)(void *))
+{
+ widget_buttonimage_t *new;
+
+ new = malloc( sizeof(widget_buttonimage_t) );
+ new->image = image;
+ new->x = x;
+ new->y = y;
+ new->w = image->w/2;
+ new->h = image->h;
+ new->active = 0;
+ new->fce_event = fce_event;
+
+ return new;
+}
+
+void drawWidgetButtonimage(widget_buttonimage_t *p)
+{
+ drawImage(p->image, p->x, p->y, p->active*p->w, 0, p->w, p->h);
+}
+
+void eventWidgetButtonimage(widget_buttonimage_t *p)
+{
+ static int time = 0;
+ int x, y;
+
+ if( time > 0)
+ {
+ time--;
+ return;
+ }
+
+ getMousePosition(&x, &y);
+
+ if( x >= p->x && x <= p->x+p->w &&
+ y >= p->y && y <= p->y+p->h &&
+ isMouseClicked() )
+ {
+ time = WIDGET_BUTTONIMAGE_TIME;
+ p->fce_event(p);
+ }
+}
+
+void destroyWidgetButtonimage(widget_buttonimage_t *p)
+{
+ free(p);
+}