소스 검색

v1

First commit.
coldiary 6 년 전
부모
커밋
2b2ab5e3cd
36개의 변경된 파일1186개의 추가작업 그리고 5개의 파일을 삭제
  1. 97
    0
      Mario Sokoban.xcodeproj/project.pbxproj
  2. 41
    0
      Mario Sokoban.xcodeproj/project.xcworkspace/xcshareddata/Mario Sokoban.xccheckout
  3. 20
    0
      Mario Sokoban.xcodeproj/project.xcworkspace/xcuserdata/Coldiary.xcuserdatad/WorkspaceSettings.xcsettings
  4. 5
    0
      Mario Sokoban.xcodeproj/xcuserdata/Coldiary.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  5. 2
    1
      Mario Sokoban.xcodeproj/xcuserdata/Coldiary.xcuserdatad/xcschemes/Mario Sokoban.xcscheme
  6. 21
    0
      Mario Sokoban/constantes.h
  7. 0
    0
      Mario Sokoban/debutant.lvl
  8. 140
    0
      Mario Sokoban/difficulty.c
  9. 14
    0
      Mario Sokoban/difficulty.h
  10. 192
    0
      Mario Sokoban/editor.c
  11. 14
    0
      Mario Sokoban/editor.h
  12. 295
    0
      Mario Sokoban/game.c
  13. 16
    0
      Mario Sokoban/game.h
  14. 102
    0
      Mario Sokoban/level.c
  15. 15
    0
      Mario Sokoban/level.h
  16. 1
    0
      Mario Sokoban/level.lvl
  17. 8
    0
      Mario Sokoban/levels/debutant.lvl
  18. 10
    0
      Mario Sokoban/levels/intermediaire.lvl
  19. 1
    0
      Mario Sokoban/levels/level.lvl
  20. 1
    0
      Mario Sokoban/levels/menu.lvl
  21. 38
    4
      Mario Sokoban/main.c
  22. 137
    0
      Mario Sokoban/menu.c
  23. 16
    0
      Mario Sokoban/menu.h
  24. BIN
      Mario Sokoban/sprites/caisse.jpg
  25. BIN
      Mario Sokoban/sprites/caisse_ok.jpg
  26. BIN
      Mario Sokoban/sprites/commandes.png
  27. BIN
      Mario Sokoban/sprites/difficulty.png
  28. BIN
      Mario Sokoban/sprites/draw.png
  29. BIN
      Mario Sokoban/sprites/mario_bas.gif
  30. BIN
      Mario Sokoban/sprites/mario_droite.gif
  31. BIN
      Mario Sokoban/sprites/mario_gauche.gif
  32. BIN
      Mario Sokoban/sprites/mario_haut.gif
  33. BIN
      Mario Sokoban/sprites/menu.png
  34. BIN
      Mario Sokoban/sprites/mur.jpg
  35. BIN
      Mario Sokoban/sprites/objectif.png
  36. BIN
      Mario Sokoban/sprites/win.png

+ 97
- 0
Mario Sokoban.xcodeproj/project.pbxproj 파일 보기

7
 	objects = {
7
 	objects = {
8
 
8
 
9
 /* Begin PBXBuildFile section */
9
 /* Begin PBXBuildFile section */
10
+		6A18D67C18B35DD80065943B /* difficulty.c in Sources */ = {isa = PBXBuildFile; fileRef = 6A18D67B18B35DD80065943B /* difficulty.c */; };
11
+		6A251D3E18B0B6EB00BAE4F7 /* level.c in Sources */ = {isa = PBXBuildFile; fileRef = 6A251D3D18B0B6EB00BAE4F7 /* level.c */; };
12
+		6A251D4918B110DC00BAE4F7 /* editor.c in Sources */ = {isa = PBXBuildFile; fileRef = 6A251D4818B110DC00BAE4F7 /* editor.c */; };
13
+		6A9E269818B09DC10088D095 /* game.c in Sources */ = {isa = PBXBuildFile; fileRef = 6A9E269718B09DC10088D095 /* game.c */; };
10
 		6AA6E9CB18AF75B800DBBD19 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AA6E9CA18AF75B800DBBD19 /* main.c */; };
14
 		6AA6E9CB18AF75B800DBBD19 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AA6E9CA18AF75B800DBBD19 /* main.c */; };
11
 		6AA6E9CD18AF75B800DBBD19 /* Mario_Sokoban.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */; };
15
 		6AA6E9CD18AF75B800DBBD19 /* Mario_Sokoban.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */; };
16
+		6AA6E9D418AF75E800DBBD19 /* SDL2_image.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6AA6E9D318AF75E800DBBD19 /* SDL2_image.framework */; };
17
+		6AA6E9D618AF761800DBBD19 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6AA6E9D518AF761800DBBD19 /* SDL2.framework */; };
18
+		6AA6E9E218AF7EC800DBBD19 /* menu.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AA6E9E118AF7EC800DBBD19 /* menu.c */; };
12
 /* End PBXBuildFile section */
19
 /* End PBXBuildFile section */
13
 
20
 
14
 /* Begin PBXCopyFilesBuildPhase section */
21
 /* Begin PBXCopyFilesBuildPhase section */
25
 /* End PBXCopyFilesBuildPhase section */
32
 /* End PBXCopyFilesBuildPhase section */
26
 
33
 
27
 /* Begin PBXFileReference section */
34
 /* Begin PBXFileReference section */
35
+		6A18D67B18B35DD80065943B /* difficulty.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = difficulty.c; sourceTree = "<group>"; };
36
+		6A18D67D18B35FB90065943B /* difficulty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = difficulty.h; sourceTree = "<group>"; };
37
+		6A251D3D18B0B6EB00BAE4F7 /* level.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = level.c; sourceTree = "<group>"; };
38
+		6A251D3F18B0B79F00BAE4F7 /* level.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = level.h; sourceTree = "<group>"; };
39
+		6A251D4618B10D5300BAE4F7 /* level.lvl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = level.lvl; sourceTree = "<group>"; wrapsLines = 0; };
40
+		6A251D4718B10D5300BAE4F7 /* menu.lvl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = menu.lvl; sourceTree = "<group>"; wrapsLines = 0; };
41
+		6A251D4818B110DC00BAE4F7 /* editor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = editor.c; sourceTree = "<group>"; };
42
+		6A251D4A18B110E600BAE4F7 /* editor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = editor.h; sourceTree = "<group>"; };
43
+		6A9E0E3E18B36C5D004FBDCB /* intermediaire.lvl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = intermediaire.lvl; sourceTree = "<group>"; };
44
+		6A9E269618B096C80088D095 /* constantes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = constantes.h; sourceTree = "<group>"; };
45
+		6A9E269718B09DC10088D095 /* game.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = game.c; sourceTree = "<group>"; };
46
+		6A9E269918B09DF30088D095 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
28
 		6AA6E9C718AF75B800DBBD19 /* Mario Sokoban */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Mario Sokoban"; sourceTree = BUILT_PRODUCTS_DIR; };
47
 		6AA6E9C718AF75B800DBBD19 /* Mario Sokoban */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Mario Sokoban"; sourceTree = BUILT_PRODUCTS_DIR; };
29
 		6AA6E9CA18AF75B800DBBD19 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
48
 		6AA6E9CA18AF75B800DBBD19 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
30
 		6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Mario_Sokoban.1; sourceTree = "<group>"; };
49
 		6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Mario_Sokoban.1; sourceTree = "<group>"; };
50
+		6AA6E9D318AF75E800DBBD19 /* SDL2_image.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_image.framework; path = ../../../../Library/Frameworks/SDL2_image.framework; sourceTree = "<group>"; };
51
+		6AA6E9D518AF761800DBBD19 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = ../../../../Library/Frameworks/SDL2.framework; sourceTree = "<group>"; };
52
+		6AA6E9D818AF774B00DBBD19 /* caisse.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = caisse.jpg; sourceTree = "<group>"; };
53
+		6AA6E9D918AF774B00DBBD19 /* caisse_ok.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = caisse_ok.jpg; sourceTree = "<group>"; };
54
+		6AA6E9DA18AF774B00DBBD19 /* mario_bas.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = mario_bas.gif; sourceTree = "<group>"; };
55
+		6AA6E9DB18AF774B00DBBD19 /* mario_droite.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = mario_droite.gif; sourceTree = "<group>"; };
56
+		6AA6E9DC18AF774B00DBBD19 /* mario_gauche.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = mario_gauche.gif; sourceTree = "<group>"; };
57
+		6AA6E9DD18AF774B00DBBD19 /* mario_haut.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = mario_haut.gif; sourceTree = "<group>"; };
58
+		6AA6E9DF18AF774B00DBBD19 /* mur.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = mur.jpg; sourceTree = "<group>"; };
59
+		6AA6E9E018AF774B00DBBD19 /* objectif.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = objectif.png; sourceTree = "<group>"; };
60
+		6AA6E9E118AF7EC800DBBD19 /* menu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = menu.c; sourceTree = "<group>"; };
61
+		6AA6E9E318AF870900DBBD19 /* menu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu.h; sourceTree = "<group>"; };
62
+		6AE7260818B2A03C00E298E0 /* commandes.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = commandes.png; sourceTree = "<group>"; };
63
+		6AE7260918B2A03C00E298E0 /* draw.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = draw.png; sourceTree = "<group>"; };
64
+		6AE7260A18B2A03C00E298E0 /* win.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = win.png; sourceTree = "<group>"; };
65
+		6AE7260B18B2A34700E298E0 /* menu.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu.png; sourceTree = "<group>"; };
66
+		6AE7260D18B2AEA200E298E0 /* debutant.lvl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = debutant.lvl; sourceTree = "<group>"; };
31
 /* End PBXFileReference section */
67
 /* End PBXFileReference section */
32
 
68
 
33
 /* Begin PBXFrameworksBuildPhase section */
69
 /* Begin PBXFrameworksBuildPhase section */
35
 			isa = PBXFrameworksBuildPhase;
71
 			isa = PBXFrameworksBuildPhase;
36
 			buildActionMask = 2147483647;
72
 			buildActionMask = 2147483647;
37
 			files = (
73
 			files = (
74
+				6AA6E9D618AF761800DBBD19 /* SDL2.framework in Frameworks */,
75
+				6AA6E9D418AF75E800DBBD19 /* SDL2_image.framework in Frameworks */,
38
 			);
76
 			);
39
 			runOnlyForDeploymentPostprocessing = 0;
77
 			runOnlyForDeploymentPostprocessing = 0;
40
 		};
78
 		};
41
 /* End PBXFrameworksBuildPhase section */
79
 /* End PBXFrameworksBuildPhase section */
42
 
80
 
43
 /* Begin PBXGroup section */
81
 /* Begin PBXGroup section */
82
+		6A251D4218B0B88000BAE4F7 /* levels */ = {
83
+			isa = PBXGroup;
84
+			children = (
85
+				6A9E0E3E18B36C5D004FBDCB /* intermediaire.lvl */,
86
+				6AE7260D18B2AEA200E298E0 /* debutant.lvl */,
87
+				6A251D4618B10D5300BAE4F7 /* level.lvl */,
88
+				6A251D4718B10D5300BAE4F7 /* menu.lvl */,
89
+			);
90
+			path = levels;
91
+			sourceTree = "<group>";
92
+		};
44
 		6AA6E9BE18AF75B800DBBD19 = {
93
 		6AA6E9BE18AF75B800DBBD19 = {
45
 			isa = PBXGroup;
94
 			isa = PBXGroup;
46
 			children = (
95
 			children = (
96
+				6AA6E9D518AF761800DBBD19 /* SDL2.framework */,
97
+				6AA6E9D318AF75E800DBBD19 /* SDL2_image.framework */,
47
 				6AA6E9C918AF75B800DBBD19 /* Mario Sokoban */,
98
 				6AA6E9C918AF75B800DBBD19 /* Mario Sokoban */,
48
 				6AA6E9C818AF75B800DBBD19 /* Products */,
99
 				6AA6E9C818AF75B800DBBD19 /* Products */,
49
 			);
100
 			);
61
 			isa = PBXGroup;
112
 			isa = PBXGroup;
62
 			children = (
113
 			children = (
63
 				6AA6E9CA18AF75B800DBBD19 /* main.c */,
114
 				6AA6E9CA18AF75B800DBBD19 /* main.c */,
115
+				6A9E269618B096C80088D095 /* constantes.h */,
116
+				6A9E269718B09DC10088D095 /* game.c */,
117
+				6A9E269918B09DF30088D095 /* game.h */,
118
+				6AA6E9E118AF7EC800DBBD19 /* menu.c */,
119
+				6AA6E9E318AF870900DBBD19 /* menu.h */,
120
+				6A18D67B18B35DD80065943B /* difficulty.c */,
121
+				6A18D67D18B35FB90065943B /* difficulty.h */,
122
+				6A251D4818B110DC00BAE4F7 /* editor.c */,
123
+				6A251D4A18B110E600BAE4F7 /* editor.h */,
124
+				6A251D3D18B0B6EB00BAE4F7 /* level.c */,
125
+				6A251D3F18B0B79F00BAE4F7 /* level.h */,
64
 				6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */,
126
 				6AA6E9CC18AF75B800DBBD19 /* Mario_Sokoban.1 */,
127
+				6A251D4218B0B88000BAE4F7 /* levels */,
128
+				6AA6E9D718AF774B00DBBD19 /* sprites */,
65
 			);
129
 			);
66
 			path = "Mario Sokoban";
130
 			path = "Mario Sokoban";
67
 			sourceTree = "<group>";
131
 			sourceTree = "<group>";
68
 		};
132
 		};
133
+		6AA6E9D718AF774B00DBBD19 /* sprites */ = {
134
+			isa = PBXGroup;
135
+			children = (
136
+				6AE7260B18B2A34700E298E0 /* menu.png */,
137
+				6AE7260818B2A03C00E298E0 /* commandes.png */,
138
+				6AE7260918B2A03C00E298E0 /* draw.png */,
139
+				6AE7260A18B2A03C00E298E0 /* win.png */,
140
+				6AA6E9D818AF774B00DBBD19 /* caisse.jpg */,
141
+				6AA6E9D918AF774B00DBBD19 /* caisse_ok.jpg */,
142
+				6AA6E9DA18AF774B00DBBD19 /* mario_bas.gif */,
143
+				6AA6E9DB18AF774B00DBBD19 /* mario_droite.gif */,
144
+				6AA6E9DC18AF774B00DBBD19 /* mario_gauche.gif */,
145
+				6AA6E9DD18AF774B00DBBD19 /* mario_haut.gif */,
146
+				6AA6E9DF18AF774B00DBBD19 /* mur.jpg */,
147
+				6AA6E9E018AF774B00DBBD19 /* objectif.png */,
148
+			);
149
+			path = sprites;
150
+			sourceTree = "<group>";
151
+		};
69
 /* End PBXGroup section */
152
 /* End PBXGroup section */
70
 
153
 
71
 /* Begin PBXNativeTarget section */
154
 /* Begin PBXNativeTarget section */
117
 			isa = PBXSourcesBuildPhase;
200
 			isa = PBXSourcesBuildPhase;
118
 			buildActionMask = 2147483647;
201
 			buildActionMask = 2147483647;
119
 			files = (
202
 			files = (
203
+				6A18D67C18B35DD80065943B /* difficulty.c in Sources */,
204
+				6A251D3E18B0B6EB00BAE4F7 /* level.c in Sources */,
205
+				6A9E269818B09DC10088D095 /* game.c in Sources */,
206
+				6AA6E9E218AF7EC800DBBD19 /* menu.c in Sources */,
207
+				6A251D4918B110DC00BAE4F7 /* editor.c in Sources */,
120
 				6AA6E9CB18AF75B800DBBD19 /* main.c in Sources */,
208
 				6AA6E9CB18AF75B800DBBD19 /* main.c in Sources */,
121
 			);
209
 			);
122
 			runOnlyForDeploymentPostprocessing = 0;
210
 			runOnlyForDeploymentPostprocessing = 0;
195
 		6AA6E9D118AF75B800DBBD19 /* Debug */ = {
283
 		6AA6E9D118AF75B800DBBD19 /* Debug */ = {
196
 			isa = XCBuildConfiguration;
284
 			isa = XCBuildConfiguration;
197
 			buildSettings = {
285
 			buildSettings = {
286
+				FRAMEWORK_SEARCH_PATHS = (
287
+					"$(inherited)",
288
+					"$(LOCAL_LIBRARY_DIR)/Frameworks",
289
+				);
198
 				PRODUCT_NAME = "$(TARGET_NAME)";
290
 				PRODUCT_NAME = "$(TARGET_NAME)";
199
 			};
291
 			};
200
 			name = Debug;
292
 			name = Debug;
202
 		6AA6E9D218AF75B800DBBD19 /* Release */ = {
294
 		6AA6E9D218AF75B800DBBD19 /* Release */ = {
203
 			isa = XCBuildConfiguration;
295
 			isa = XCBuildConfiguration;
204
 			buildSettings = {
296
 			buildSettings = {
297
+				FRAMEWORK_SEARCH_PATHS = (
298
+					"$(inherited)",
299
+					"$(LOCAL_LIBRARY_DIR)/Frameworks",
300
+				);
205
 				PRODUCT_NAME = "$(TARGET_NAME)";
301
 				PRODUCT_NAME = "$(TARGET_NAME)";
206
 			};
302
 			};
207
 			name = Release;
303
 			name = Release;
225
 				6AA6E9D218AF75B800DBBD19 /* Release */,
321
 				6AA6E9D218AF75B800DBBD19 /* Release */,
226
 			);
322
 			);
227
 			defaultConfigurationIsVisible = 0;
323
 			defaultConfigurationIsVisible = 0;
324
+			defaultConfigurationName = Release;
228
 		};
325
 		};
229
 /* End XCConfigurationList section */
326
 /* End XCConfigurationList section */
230
 	};
327
 	};

+ 41
- 0
Mario Sokoban.xcodeproj/project.xcworkspace/xcshareddata/Mario Sokoban.xccheckout 파일 보기

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>IDESourceControlProjectFavoriteDictionaryKey</key>
6
+	<false/>
7
+	<key>IDESourceControlProjectIdentifier</key>
8
+	<string>AA2296E3-A43E-4F80-90FD-403F86439B6B</string>
9
+	<key>IDESourceControlProjectName</key>
10
+	<string>Mario Sokoban</string>
11
+	<key>IDESourceControlProjectOriginsDictionary</key>
12
+	<dict>
13
+		<key>4E0CDC9A-0DEC-4760-BD22-5203362A5DA0</key>
14
+		<string>https://github.com/coldiary/Mario-Sokoban.git</string>
15
+	</dict>
16
+	<key>IDESourceControlProjectPath</key>
17
+	<string>Mario Sokoban.xcodeproj/project.xcworkspace</string>
18
+	<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
19
+	<dict>
20
+		<key>4E0CDC9A-0DEC-4760-BD22-5203362A5DA0</key>
21
+		<string>../..</string>
22
+	</dict>
23
+	<key>IDESourceControlProjectURL</key>
24
+	<string>https://github.com/coldiary/Mario-Sokoban.git</string>
25
+	<key>IDESourceControlProjectVersion</key>
26
+	<integer>110</integer>
27
+	<key>IDESourceControlProjectWCCIdentifier</key>
28
+	<string>4E0CDC9A-0DEC-4760-BD22-5203362A5DA0</string>
29
+	<key>IDESourceControlProjectWCConfigurations</key>
30
+	<array>
31
+		<dict>
32
+			<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
33
+			<string>public.vcs.git</string>
34
+			<key>IDESourceControlWCCIdentifierKey</key>
35
+			<string>4E0CDC9A-0DEC-4760-BD22-5203362A5DA0</string>
36
+			<key>IDESourceControlWCCName</key>
37
+			<string>Mario Sokoban</string>
38
+		</dict>
39
+	</array>
40
+</dict>
41
+</plist>

+ 20
- 0
Mario Sokoban.xcodeproj/project.xcworkspace/xcuserdata/Coldiary.xcuserdatad/WorkspaceSettings.xcsettings 파일 보기

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>BuildLocationStyle</key>
6
+	<string>UseAppPreferences</string>
7
+	<key>CustomBuildLocationType</key>
8
+	<string>RelativeToDerivedData</string>
9
+	<key>DerivedDataLocationStyle</key>
10
+	<string>Default</string>
11
+	<key>IssueFilterStyle</key>
12
+	<string>ShowActiveSchemeOnly</string>
13
+	<key>LiveSourceIssuesEnabled</key>
14
+	<true/>
15
+	<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
16
+	<true/>
17
+	<key>SnapshotLocationStyle</key>
18
+	<string>Default</string>
19
+</dict>
20
+</plist>

+ 5
- 0
Mario Sokoban.xcodeproj/xcuserdata/Coldiary.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist 파일 보기

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<Bucket
3
+   type = "1"
4
+   version = "2.0">
5
+</Bucket>

+ 2
- 1
Mario Sokoban.xcodeproj/xcuserdata/Coldiary.xcuserdatad/xcschemes/Mario Sokoban.xcscheme 파일 보기

43
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
43
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
44
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
45
       launchStyle = "0"
45
       launchStyle = "0"
46
-      useCustomWorkingDirectory = "NO"
46
+      useCustomWorkingDirectory = "YES"
47
+      customWorkingDirectory = "/Users/Coldiary/Projets Code/Mario Sokoban/Mario Sokoban"
47
       buildConfiguration = "Debug"
48
       buildConfiguration = "Debug"
48
       ignoresPersistentStateOnLaunch = "NO"
49
       ignoresPersistentStateOnLaunch = "NO"
49
       debugDocumentVersioning = "YES"
50
       debugDocumentVersioning = "YES"

+ 21
- 0
Mario Sokoban/constantes.h 파일 보기

1
+//
2
+//  constantes.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_constantes_h
10
+#define Mario_Sokoban_constantes_h
11
+
12
+#define TAILLE_BLOC 34
13
+#define NB_BLOCS_LARGEUR 12
14
+#define NB_BLOCS_HAUTEUR 12
15
+#define LARGEUR_ECRAN TAILLE_BLOC*NB_BLOCS_LARGEUR
16
+#define HAUTEUR_ECRAN TAILLE_BLOC*NB_BLOCS_HAUTEUR
17
+
18
+enum {HAUT,BAS,GAUCHE,DROITE};
19
+enum {VIDE, WALL, BOX, TARGET, MARIO, BOX_OK};
20
+
21
+#endif

+ 0
- 0
Mario Sokoban/debutant.lvl 파일 보기


+ 140
- 0
Mario Sokoban/difficulty.c 파일 보기

1
+//
2
+//  difficulty.c
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-18.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+#include "game.h"
15
+#include "level.h"
16
+
17
+
18
+int difficulty(SDL_Window *ecran, SDL_Surface *screen)
19
+{
20
+    int difficulty = 1, running = 1, i = 0, j = 0, target_r = 0;
21
+    int map[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
22
+    SDL_Event event;
23
+    SDL_Surface *mario[4] = {NULL};
24
+    SDL_Surface *wall = NULL, *marioActuel = NULL, *box = NULL, *target = NULL, *boxOK = NULL, *diff = NULL;
25
+    SDL_Rect position, posMario;
26
+    wall = IMG_Load("sprites/mur.jpg");
27
+    box = IMG_Load("sprites/caisse.jpg");
28
+    boxOK = IMG_Load("sprites/caisse_ok.jpg");
29
+    target = IMG_Load("sprites/objectif.png");
30
+    diff = IMG_Load("sprites/difficulty.png");
31
+    mario[HAUT] = IMG_Load("sprites/mario_haut.gif");
32
+    mario[BAS] = IMG_Load("sprites/mario_bas.gif");
33
+    mario[GAUCHE] = IMG_Load("sprites/mario_gauche.gif");
34
+    mario[DROITE] = IMG_Load("sprites/mario_droite.gif");
35
+    marioActuel = mario[BAS];
36
+    if (loadLevel(0, 0, map) == 0) {
37
+        exit(EXIT_FAILURE);
38
+    }
39
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
40
+    {
41
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
42
+        {
43
+            if (map[i][j] == MARIO)
44
+            {
45
+                posMario.x = i;
46
+                posMario.y = j;
47
+                map[i][j] = VIDE;
48
+            }
49
+        }
50
+    }
51
+    while (running) {
52
+        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
53
+        target_r = 0;
54
+        for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
55
+        {
56
+            for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
57
+            {
58
+                position.x = i * TAILLE_BLOC;
59
+                position.y = j * TAILLE_BLOC;
60
+                
61
+                switch(map[i][j])
62
+                {
63
+                    case WALL:
64
+                        SDL_BlitSurface(wall, NULL, screen, &position);
65
+                        break;
66
+                    case BOX:
67
+                        SDL_BlitSurface(box, NULL, screen, &position);
68
+                        break;
69
+                    case BOX_OK:
70
+                        SDL_BlitSurface(boxOK, NULL, screen, &position);
71
+                        break;
72
+                    case TARGET:
73
+                        SDL_BlitSurface(target, NULL, screen, &position);
74
+                        target_r = 1;
75
+                        break;
76
+                }
77
+            }
78
+        } // Dessine la carte
79
+        position.x = 0;
80
+        position.y = 0;
81
+        SDL_BlitSurface(diff, NULL, screen, &position);
82
+        position.x = posMario.x * TAILLE_BLOC;
83
+        position.y = posMario.y * TAILLE_BLOC;
84
+        SDL_BlitSurface(marioActuel, NULL, screen, &position); // Place le joueur
85
+        SDL_UpdateWindowSurface(ecran);
86
+        if (!target_r) {
87
+            difficulty = 1;
88
+            running = 0; // Test de victoire
89
+        }
90
+        SDL_WaitEvent(&event);
91
+        switch (event.type){
92
+            case SDL_QUIT:
93
+                exit(EXIT_SUCCESS);
94
+                break;
95
+            case SDL_KEYDOWN:
96
+                switch (event.key.keysym.sym) {
97
+                    case SDLK_ESCAPE:
98
+                        exit(EXIT_SUCCESS);
99
+                        break;
100
+                    case SDLK_1:
101
+                        difficulty = 1;
102
+                        running = 0;
103
+                        break;
104
+                    case SDLK_2:
105
+                        difficulty = 2;
106
+                        running = 0;
107
+                        break;
108
+                    case SDLK_3:
109
+                        difficulty = 3;
110
+                        running = 0;
111
+                        break;
112
+                    case SDLK_UP:
113
+                        marioActuel = mario[HAUT];
114
+                        mooveMario(map, &posMario, HAUT);
115
+                        break;
116
+                    case SDLK_DOWN:
117
+                        marioActuel = mario[BAS];
118
+                        mooveMario(map, &posMario, BAS);
119
+                        break;
120
+                    case SDLK_RIGHT:
121
+                        marioActuel = mario[DROITE];
122
+                        mooveMario(map, &posMario, DROITE);
123
+                        break;
124
+                    case SDLK_LEFT:
125
+                        marioActuel = mario[GAUCHE];
126
+                        mooveMario(map, &posMario, GAUCHE);
127
+                        break;
128
+                }
129
+        }
130
+    } // Wait for action
131
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
132
+    SDL_UpdateWindowSurface(ecran);
133
+    SDL_FreeSurface(wall);
134
+    SDL_FreeSurface(box);
135
+    SDL_FreeSurface(boxOK);
136
+    SDL_FreeSurface(target);
137
+    for (i = 0 ; i < 4 ; i++)
138
+        SDL_FreeSurface(mario[i]); // Libère la mémoire
139
+    return difficulty;
140
+}

+ 14
- 0
Mario Sokoban/difficulty.h 파일 보기

1
+//
2
+//  difficulty.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-18.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_difficulty_h
10
+#define Mario_Sokoban_difficulty_h
11
+
12
+int difficulty(SDL_Window*, SDL_Surface*);
13
+
14
+#endif

+ 192
- 0
Mario Sokoban/editor.c 파일 보기

1
+//
2
+//  editor.c
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+#include "level.h"
15
+
16
+void editor(SDL_Window *ecran, SDL_Surface *screen)
17
+{
18
+    SDL_Surface *wall = NULL, *box = NULL, *target = NULL, *mario = NULL, *draw = NULL, *boxOK = NULL, *object = NULL;
19
+    SDL_Rect position, posStart, posPointer;
20
+    SDL_Event event;
21
+    int running = 1, i = 0, j = 0, leftClicOn = 0, rightClicOn = 0, curObject = WALL, continuer = 0, start = 0;
22
+    int map[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
23
+    wall = IMG_Load("sprites/mur.jpg");
24
+    box = IMG_Load("sprites/caisse.jpg");
25
+    target = IMG_Load("sprites/objectif.png");
26
+    mario = IMG_Load("sprites/mario_bas.gif");
27
+    draw = IMG_Load("sprites/draw.png");
28
+    boxOK = IMG_Load("sprites/caisse_ok.jpg");
29
+    if (loadLevel(0, 0, map) == 0) {
30
+        exit(EXIT_FAILURE);
31
+    }
32
+    position.x = 0;
33
+    position.y = 0;
34
+    SDL_BlitSurface(draw, NULL, screen, &position);
35
+    SDL_UpdateWindowSurface(ecran);
36
+    while (!continuer) {
37
+        SDL_WaitEvent(&event);
38
+        switch(event.type)
39
+        {
40
+            case SDL_QUIT:
41
+                exit(EXIT_SUCCESS);
42
+                break;
43
+            case SDL_KEYDOWN:
44
+                switch(event.key.keysym.sym)
45
+            {
46
+                case SDLK_ESCAPE:
47
+                    running = 0;
48
+                    break;
49
+                case SDLK_RETURN:
50
+                    continuer = 1;
51
+                    break;
52
+                case SDLK_SPACE:
53
+                    continuer = 1;
54
+                    break;
55
+            }
56
+                break;
57
+        } // Acton du joueur
58
+    }
59
+    while (running) {
60
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
61
+        for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
62
+        {
63
+            for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
64
+            {
65
+                position.x = i * TAILLE_BLOC;
66
+                position.y = j * TAILLE_BLOC;
67
+                
68
+                if (map[i][j] == MARIO) {
69
+                    start = 1;
70
+                    posStart.x = position.x;
71
+                    posStart.y = position.y;
72
+                }
73
+                switch(map[i][j])
74
+                {
75
+                    case WALL:
76
+                        SDL_BlitSurface(wall, NULL, screen, &position);
77
+                        break;
78
+                    case BOX:
79
+                        SDL_BlitSurface(box, NULL, screen, &position);
80
+                        break;
81
+                    case MARIO:
82
+                        SDL_BlitSurface(mario, NULL, screen, &position);
83
+                        break;
84
+                    case TARGET:
85
+                        SDL_BlitSurface(target, NULL, screen, &position);
86
+                        break;
87
+                    case BOX_OK:
88
+                        SDL_BlitSurface(boxOK, NULL, screen, &position);
89
+                        break;
90
+                }
91
+            }
92
+        } // Dessine la map
93
+        switch (curObject) {
94
+        case WALL:
95
+                object = wall;
96
+                break;
97
+        case BOX:
98
+                object = box;
99
+                break;
100
+        case MARIO:
101
+                object = mario;
102
+                break;
103
+        case TARGET:
104
+                object = target;
105
+                break;
106
+        case BOX_OK:
107
+                object = boxOK;
108
+                break;
109
+        }
110
+    SDL_BlitSurface(object, NULL, screen, &posPointer);
111
+    SDL_UpdateWindowSurface(ecran);
112
+    SDL_WaitEvent(&event);
113
+        switch(event.type)
114
+        {
115
+            case SDL_QUIT:
116
+                exit(EXIT_FAILURE);
117
+                break;
118
+            case SDL_KEYDOWN:
119
+                switch(event.key.keysym.sym) {
120
+                    case SDLK_ESCAPE:
121
+                        running = 0;
122
+                        break;
123
+                    case SDLK_s:
124
+                        saveLevel(map);
125
+                        break;
126
+                    case SDLK_l:
127
+                        loadLevel(0, 0, map);
128
+                        break;
129
+                    case SDLK_1:
130
+                        curObject = WALL;
131
+                        break;
132
+                    case SDLK_2:
133
+                        curObject = BOX;
134
+                        break;
135
+                    case SDLK_3:
136
+                        curObject = TARGET;
137
+                        break;
138
+                    case SDLK_4:
139
+                        curObject = MARIO;
140
+                        break;
141
+                    case SDLK_5:
142
+                        curObject = BOX_OK;
143
+                        break;
144
+                }
145
+                break;
146
+            case SDL_MOUSEBUTTONDOWN:
147
+                if (event.button.button == SDL_BUTTON_LEFT)
148
+                {
149
+                    if (curObject == MARIO) {
150
+                        map[posStart.x/TAILLE_BLOC][posStart.y/TAILLE_BLOC] = VIDE;
151
+                        start = 0;
152
+                    }
153
+                    map[event.button.x / TAILLE_BLOC][event.button.y / TAILLE_BLOC] = curObject;
154
+                    leftClicOn = 1;
155
+                }
156
+                else if (event.button.button == SDL_BUTTON_RIGHT)
157
+                {
158
+                    map[event.button.x / TAILLE_BLOC][event.button.y /TAILLE_BLOC] = VIDE;
159
+                    rightClicOn = 1;
160
+                }
161
+                break;
162
+            case SDL_MOUSEBUTTONUP:
163
+                if (event.button.button == SDL_BUTTON_LEFT)
164
+                    leftClicOn = 0;
165
+                else if (event.button.button == SDL_BUTTON_RIGHT)
166
+                    rightClicOn = 0;
167
+                break;
168
+            case SDL_MOUSEMOTION:
169
+                if (leftClicOn)
170
+                {
171
+                    if (curObject == MARIO) {
172
+                        break;
173
+                    }
174
+                    map[event.motion.x / TAILLE_BLOC][event.motion.y / TAILLE_BLOC] = curObject;
175
+                }
176
+                else if (rightClicOn) //
177
+                {
178
+                    map[event.motion.x / TAILLE_BLOC][event.motion.y / TAILLE_BLOC] = VIDE;
179
+                }
180
+                else {
181
+                    posPointer.x = event.motion.x;
182
+                    posPointer.y = event.motion.y;
183
+                    break;
184
+                }
185
+                break;
186
+        } // Acton du joueur
187
+    } // Boucle principale
188
+    SDL_FreeSurface(wall);
189
+    SDL_FreeSurface(box);
190
+    SDL_FreeSurface(target);
191
+    SDL_FreeSurface(mario); // Libère la mémoire
192
+}

+ 14
- 0
Mario Sokoban/editor.h 파일 보기

1
+//
2
+//  editor.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_editor_h
10
+#define Mario_Sokoban_editor_h
11
+
12
+void editor(SDL_Window*, SDL_Surface*);
13
+
14
+#endif

+ 295
- 0
Mario Sokoban/game.c 파일 보기

1
+//
2
+//  game.c
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+#include "level.h"
15
+
16
+void mooveMario(int map[][NB_BLOCS_HAUTEUR], SDL_Rect*, int);
17
+void mooveBox(int*, int*);
18
+
19
+void game(int diff, SDL_Window *ecran, SDL_Surface *screen)
20
+{
21
+    SDL_Surface *mario[4] = {NULL};
22
+    SDL_Surface *wall = NULL, *marioActuel = NULL, *box = NULL, *target = NULL, *boxOK = NULL, *win = NULL, *commandes = NULL;
23
+    SDL_Rect position, posMario;
24
+    SDL_Event event;
25
+    int running = 1, target_r = 0, i = 0, j = 0, returnMenu = 0, continuer = 0, niveau = 0, nbLevel = 0;
26
+    int map[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
27
+    wall = IMG_Load("sprites/mur.jpg");
28
+    box = IMG_Load("sprites/caisse.jpg");
29
+    boxOK = IMG_Load("sprites/caisse_ok.jpg");
30
+    target = IMG_Load("sprites/objectif.png");
31
+    win = IMG_Load("sprites/win.png");
32
+    commandes = IMG_Load("sprites/commandes.png");
33
+    mario[HAUT] = IMG_Load("sprites/mario_haut.gif");
34
+    mario[BAS] = IMG_Load("sprites/mario_bas.gif");
35
+    mario[GAUCHE] = IMG_Load("sprites/mario_gauche.gif");
36
+    mario[DROITE] = IMG_Load("sprites/mario_droite.gif");
37
+    marioActuel = mario[BAS];
38
+    nbLevel =loadLevel(niveau, diff, map);
39
+    if (nbLevel == 0) {
40
+        exit(EXIT_FAILURE);
41
+    } // Charge le niveau
42
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
43
+    {
44
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
45
+        {
46
+            if (map[i][j] == MARIO)
47
+            {
48
+                posMario.x = i;
49
+                posMario.y = j;
50
+                map[i][j] = VIDE;
51
+            }
52
+        }
53
+    } // Position du Joueur au départ
54
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
55
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
56
+    {
57
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
58
+        {
59
+            position.x = i * TAILLE_BLOC;
60
+            position.y = j * TAILLE_BLOC;
61
+            
62
+            switch(map[i][j])
63
+            {
64
+                case WALL:
65
+                    SDL_BlitSurface(wall, NULL, screen, &position);
66
+                    break;
67
+                case BOX:
68
+                    SDL_BlitSurface(box, NULL, screen, &position);
69
+                    break;
70
+                case BOX_OK:
71
+                    SDL_BlitSurface(boxOK, NULL, screen, &position);
72
+                    break;
73
+                case TARGET:
74
+                    SDL_BlitSurface(target, NULL, screen, &position);
75
+                    target_r = 1;
76
+                    break;
77
+            }
78
+        }
79
+    } // Dessine la map
80
+    position.x = 0;
81
+    position.y = 0;
82
+    SDL_BlitSurface(commandes, NULL, screen, &position);
83
+    position.x = posMario.x * TAILLE_BLOC;
84
+    position.y = posMario.y * TAILLE_BLOC;
85
+    SDL_BlitSurface(marioActuel, NULL, screen, &position); // Place le joueur
86
+    SDL_UpdateWindowSurface(ecran);
87
+    while (!continuer) {
88
+        SDL_WaitEvent(&event);
89
+        switch(event.type)
90
+        {
91
+            case SDL_QUIT:
92
+                exit(EXIT_SUCCESS);
93
+                break;
94
+            case SDL_KEYDOWN:
95
+                switch(event.key.keysym.sym)
96
+            {
97
+                case SDLK_ESCAPE:
98
+                    running = 0;
99
+                    returnMenu = 1;
100
+                    break;
101
+                case SDLK_RETURN:
102
+                    continuer = 1;
103
+                    break;
104
+                case SDLK_SPACE:
105
+                    continuer = 1;
106
+                    break;
107
+            }
108
+                break;
109
+        } // Acton du joueur
110
+    }
111
+    while (running) {
112
+    if (!loadLevel(niveau,diff, map)) {
113
+            exit(EXIT_FAILURE);
114
+        } // Charge le niveau
115
+        for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
116
+        {
117
+            for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
118
+            {
119
+                if (map[i][j] == MARIO)
120
+                {
121
+                    posMario.x = i;
122
+                    posMario.y = j;
123
+                    map[i][j] = VIDE;
124
+                }
125
+            }
126
+        } // Position du Joueur au départ
127
+    continuer = 0;
128
+    while (!continuer) {
129
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
130
+    target_r = 0;
131
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
132
+    {
133
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
134
+        {
135
+            position.x = i * TAILLE_BLOC;
136
+            position.y = j * TAILLE_BLOC;
137
+            
138
+            switch(map[i][j])
139
+            {
140
+                case WALL:
141
+                    SDL_BlitSurface(wall, NULL, screen, &position);
142
+                    break;
143
+                case BOX:
144
+                    SDL_BlitSurface(box, NULL, screen, &position);
145
+                    break;
146
+                case BOX_OK:
147
+                    SDL_BlitSurface(boxOK, NULL, screen, &position);
148
+                    break;
149
+                case TARGET:
150
+                    SDL_BlitSurface(target, NULL, screen, &position);
151
+                    target_r = 1;
152
+                    break;
153
+            }
154
+        }
155
+    } // Dessine la map
156
+    if (!target_r) {
157
+        continuer = 1;
158
+        niveau++;
159
+        }// change de niveau
160
+        if (niveau == nbLevel + 1) {
161
+        running = 0;// Test de victoire
162
+        }
163
+    position.x = posMario.x * TAILLE_BLOC;
164
+    position.y = posMario.y * TAILLE_BLOC;
165
+    SDL_BlitSurface(marioActuel, NULL, screen, &position); // Place le joueur
166
+    SDL_UpdateWindowSurface(ecran);
167
+    SDL_WaitEvent(&event);
168
+    switch(event.type)
169
+    {
170
+        case SDL_QUIT:
171
+            exit(EXIT_SUCCESS);
172
+            break;
173
+        case SDL_KEYDOWN:
174
+            switch(event.key.keysym.sym)
175
+        {
176
+            case SDLK_ESCAPE:
177
+                continuer = 1;
178
+                running = 0;
179
+                returnMenu = 1;
180
+                break;
181
+            case SDLK_UP:
182
+                marioActuel = mario[HAUT];
183
+                mooveMario(map, &posMario, HAUT);
184
+                break;
185
+            case SDLK_DOWN:
186
+                marioActuel = mario[BAS];
187
+                mooveMario(map, &posMario, BAS);
188
+                break;
189
+            case SDLK_RIGHT:
190
+                marioActuel = mario[DROITE];
191
+                mooveMario(map, &posMario, DROITE);
192
+                break;
193
+            case SDLK_LEFT:
194
+                marioActuel = mario[GAUCHE];
195
+                mooveMario(map, &posMario, GAUCHE);
196
+                break;
197
+        }
198
+            break;
199
+            } // Acton du joueur
200
+        }
201
+    } // Boucle principale
202
+    while (!returnMenu) {
203
+    position.x = 0;
204
+    position.y = 0;
205
+    SDL_BlitSurface(win, NULL, screen, &position);
206
+    SDL_UpdateWindowSurface(ecran);
207
+    SDL_WaitEvent(&event);
208
+    switch(event.type)
209
+    {
210
+        case SDL_QUIT:
211
+            exit(EXIT_SUCCESS);
212
+            break;
213
+        case SDL_KEYDOWN:
214
+            switch(event.key.keysym.sym)
215
+        {
216
+            case SDLK_ESCAPE:
217
+                returnMenu = 1;
218
+                break;
219
+            case SDLK_RETURN:
220
+                returnMenu = 1;
221
+                break;
222
+        }
223
+            break;
224
+    } // Acton du joueur
225
+    }
226
+    SDL_FreeSurface(wall);
227
+    SDL_FreeSurface(box);
228
+    SDL_FreeSurface(boxOK);
229
+    SDL_FreeSurface(target);
230
+    for (i = 0 ; i < 4 ; i++)
231
+        SDL_FreeSurface(mario[i]); // Libère la mémoire
232
+}
233
+
234
+void mooveMario(int map[][NB_BLOCS_HAUTEUR], SDL_Rect *pos, int direction)
235
+{
236
+    switch (direction) {
237
+        case HAUT:
238
+            if (pos->y - 1 < 0)
239
+                break;
240
+            if (map[pos->x][pos->y - 1] == WALL)
241
+                break;
242
+            if ((map[pos->x][pos->y - 1] == BOX || map[pos->x][pos->y - 1] == BOX_OK) && (pos->y - 2 < 0 || map[pos->x][pos->y - 2] == WALL || map[pos->x][pos->y - 2] == BOX || map[pos->x][pos->y - 2] == BOX_OK))
243
+                break;
244
+            mooveBox(&map[pos->x][pos->y - 1], &map[pos->x][pos->y - 2]);
245
+            // Si on arrive là, c'est qu'on peut déplacer le joueur ! On vérifie d'abord s'il y a une caisse à déplacer
246
+            pos->y--; // On peut enfin faire monter le joueur (oufff !)
247
+            break;
248
+        case BAS:
249
+            if (pos->y + 1 > 12)
250
+                break;
251
+            if (map[pos->x][pos->y + 1] == WALL)
252
+                break;
253
+            if ((map[pos->x][pos->y + 1] == BOX || map[pos->x][pos->y + 1] == BOX_OK) && (pos->y + 2 > 12 || map[pos->x][pos->y + 2] == WALL || map[pos->x][pos->y + 2] == BOX || map[pos->x][pos->y + 2] == BOX_OK))
254
+                break;
255
+            mooveBox(&map[pos->x][pos->y + 1], &map[pos->x][pos->y + 2]);
256
+            pos->y++;
257
+            break;
258
+        case GAUCHE:
259
+            if (pos->x - 1 < 0)
260
+                break;
261
+            if (map[pos->x - 1][pos->y] == WALL)
262
+                break;
263
+            if ((map[pos->x - 1][pos->y] == BOX || map[pos->x - 1][pos->y] == BOX_OK) && (pos->x - 2 < 0 || map[pos->x - 2][pos->y] == WALL || map[pos->x - 2][pos->y] == BOX || map[pos->x - 2][pos->y] == BOX_OK))
264
+                break;
265
+            mooveBox(&map[pos->x - 1][pos->y], &map[pos->x - 2][pos->y]);
266
+            pos->x--;
267
+            break;
268
+        case DROITE:
269
+            if (pos->x + 1 > 12)
270
+                break;
271
+            if (map[pos->x + 1][pos->y] == WALL)
272
+                break;
273
+            if ((map[pos->x + 1][pos->y] == BOX || map[pos->x + 1][pos->y] == BOX_OK) && (pos->x + 2 > 12 || map[pos->x + 2][pos->y] == WALL || map[pos->x + 2][pos->y] == BOX || map[pos->x + 2][pos->y] == BOX_OK))
274
+                break;
275
+            mooveBox(&map[pos->x + 1][pos->y], &map[pos->x + 2][pos->y]);
276
+            pos->x++;
277
+            break;
278
+    }
279
+}
280
+
281
+void mooveBox(int *premiereCase, int *secondeCase)
282
+{
283
+    if (*premiereCase == BOX || *premiereCase == BOX_OK)
284
+    {
285
+        if (*secondeCase == TARGET)
286
+            *secondeCase = BOX_OK;
287
+        else
288
+            *secondeCase = BOX;
289
+        
290
+        if (*premiereCase == BOX_OK)
291
+            *premiereCase = TARGET;
292
+        else
293
+            *premiereCase = VIDE;
294
+    }
295
+}

+ 16
- 0
Mario Sokoban/game.h 파일 보기

1
+//
2
+//  game.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_game_h
10
+#define Mario_Sokoban_game_h
11
+
12
+void game(int, SDL_Window*, SDL_Surface*);
13
+void mooveMario(int map[][NB_BLOCS_HAUTEUR], SDL_Rect*, int);
14
+void mooveBox(int*, int*);
15
+
16
+#endif

+ 102
- 0
Mario Sokoban/level.c 파일 보기

1
+//
2
+//  level.c
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+
15
+int loadLevel(int line, int menu, int map[][NB_BLOCS_HAUTEUR])
16
+{
17
+    FILE *level = NULL;
18
+    char codeLevel[NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1] = {0};
19
+    int i = 0, j = 0, k = 0, caracLu = 0, nbLevel = 1;
20
+    switch (menu) {
21
+        case 0:
22
+            level = fopen("levels/menu.lvl", "r");
23
+            break;
24
+        case 1:
25
+            level = fopen("levels/debutant.lvl", "r");
26
+            break;
27
+        case 2:
28
+            level = fopen("levels/intermediaire.lvl", "r");
29
+            break;
30
+        case 3:
31
+            level = fopen("levels/expert.lvl", "r");
32
+            break;
33
+        case 4:
34
+            level = fopen("levels/level.lvl", "r");
35
+            break;
36
+    }
37
+    if (level == NULL) {
38
+        return 0;
39
+    }
40
+    do
41
+    {
42
+        caracLu = fgetc(level);
43
+        if (caracLu == '\n')
44
+            nbLevel++;
45
+    } while(caracLu!= EOF);
46
+    k = line;
47
+    rewind(level);
48
+    while (k > 0)
49
+    {
50
+        caracLu = fgetc(level);
51
+        if (caracLu == '\n')
52
+            k--;
53
+    }
54
+    fgets(codeLevel, NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1, level);
55
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
56
+    {
57
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
58
+        {
59
+            switch (codeLevel[(i * NB_BLOCS_LARGEUR) + j])
60
+            {
61
+                case '0':
62
+                    map[j][i] = 0;
63
+                    break;
64
+                case '1':
65
+                    map[j][i] = 1;
66
+                    break;
67
+                case '2':
68
+                    map[j][i] = 2;
69
+                    break;
70
+                case '3':
71
+                    map[j][i] = 3;
72
+                    break;
73
+                case '4':
74
+                    map[j][i] = 4;
75
+                    break;
76
+                case '5':
77
+                    map[j][i] = 5;
78
+                    break;
79
+            }
80
+        }
81
+    } // Définit la map
82
+    fclose(level);
83
+    return nbLevel;
84
+}
85
+
86
+int saveLevel(int map[][NB_BLOCS_HAUTEUR])
87
+{
88
+    FILE *level = NULL;
89
+    int i = 0, j = 0;
90
+    level = fopen("levels/level.lvl", "w+");
91
+    if (level == NULL)
92
+        return 0;
93
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
94
+    {
95
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
96
+        {
97
+            fprintf(level, "%d", map[j][i]);
98
+        }
99
+    }
100
+    fclose(level);
101
+    return 1;
102
+}

+ 15
- 0
Mario Sokoban/level.h 파일 보기

1
+//
2
+//  level.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-16.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_level_h
10
+#define Mario_Sokoban_level_h
11
+
12
+int loadLevel(int, int, int map[][NB_BLOCS_HAUTEUR]);
13
+int saveLevel(int map[][NB_BLOCS_HAUTEUR]);
14
+
15
+#endif

+ 1
- 0
Mario Sokoban/level.lvl 파일 보기

1
+111111111111111111111111100000000001100000000001100000000001100000000001100000000001100000000001100000000001104002003001100000000001111111111111

+ 8
- 0
Mario Sokoban/levels/debutant.lvl 파일 보기

1
+111111111111100000000001104000000001100000000001100023350001100032200001100023320001100002230001100053320001100000000001100000000001111111111111
2
+111111111111100000000001104000000001100000000001100005520001100050030001100032230001100030050001100025500001100000000001100000000001111111111111
3
+111111111111100000000001104000000001100000000001100032230001100050320001100053020001100050320001100032230001100000000001100000000001111111111111
4
+111111111111100000000001104000000001100000000001100023320001100050230001100052030001100050230001100023320001100000000001100000000001111111111111
5
+111111111111100000000001104000000001100000000001100035200001100050320001100053020001100050320001100035200001100000000001100000000001111111111111
6
+111111111111100000000001104000000001100000000001100022300001100023230001100025330001100023230001100025230001100000000001100000000001111111111111
7
+111111111111100000000001104000000001100000000001100030230001100035050001100032550001100032050001100002020001100000000001100000000001111111111111
8
+111111111111100000000001104000000001100000000001100050050001100025320001100050250001100023320001100030030001100000000001100000000001111111111111

+ 10
- 0
Mario Sokoban/levels/intermediaire.lvl 파일 보기

1
+111111111111111111111111111100031111111020250111110001130011110000200011114000000011110000020011110031100011111052030111111130001111111111111111
2
+111111111111111111111111111100011111111400011111110000011111110022211111111133311111111133311111111122211111110000000111110000000111111111111111
3
+111111111111111100001111111000003111110031000011111114000011111102000111111002001111111000011111110020111111110023000011110000003011111111111111
4
+111111111111110000400011110020202011111111110011111111100111110113300011110011100011110031000011111300200111111100001111111111111111111111111111
5
+111111111111111110001111111102000111111000000111114013000111130211302111102003300011130002250011111111000111111111020111111111323111111111111111
6
+111111111111114000000111100000200111102011111111102200001111110000200111111111000011113311100011113001000011113000000111111300001111111111111111
7
+111111111111111100001111111002040111110021100111110201111111110000000111110030032011110001100011110001100011111030030111111100001111111111111111
8
+111111111111110000400111110202002111111111000111111111000111111130000311111130000311111111000111111111200111111111000111111111000111111111111111
9
+111111111111111100401111111020020111110231132011110031130011111200002111110002020011110031130011110031130011110231132011111000000111111111111111
10
+111111111111111100040111111002000011110001112011110021110011111000000011111111100011111331110011113003100011111000002011111100000111111111111111

+ 1
- 0
Mario Sokoban/levels/level.lvl 파일 보기

1
+111111111111100000000001100000000001100000000001100000000001100000000001100000000001100000000001100000000001104002003001100000000001111111111111

+ 1
- 0
Mario Sokoban/levels/menu.lvl 파일 보기

1
+111111111111100000000001100000000001100000000001100000000001100000000001100000000001100000000001100000000001104002003001100000000001111111111111

+ 38
- 4
Mario Sokoban/main.c 파일 보기

7
 //
7
 //
8
 
8
 
9
 #include <stdio.h>
9
 #include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+#include "menu.h"
15
+#include "game.h"
16
+#include "level.h"
17
+#include "editor.h"
18
+#include "difficulty.h"
19
+
20
+
10
 
21
 
11
 int main(int argc, const char * argv[])
22
 int main(int argc, const char * argv[])
12
 {
23
 {
13
-
14
-    // insert code here...
15
-    printf("Hello, World!\n");
16
-    return 0;
24
+    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
25
+        printf("Erreur lors de l'initialisation du module SDL. Erreur : %s", SDL_GetError());
26
+        exit(EXIT_FAILURE);
27
+    }
28
+    int choice = 0, diff = 1;
29
+    SDL_Window *ecran;
30
+    SDL_Surface *screen, *icon;
31
+    ecran = SDL_CreateWindow("MARIO SOKOBAN", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, LARGEUR_ECRAN, HAUTEUR_ECRAN, SDL_WINDOW_SHOWN);
32
+    screen = SDL_GetWindowSurface(ecran);
33
+    icon = IMG_Load("sprites/mario_bas.gif");
34
+    SDL_SetWindowIcon(ecran, icon);
35
+    while (choice == 0) {
36
+        choice = menu(ecran, screen);
37
+        switch (choice) {
38
+            case 1:
39
+                diff = difficulty(ecran, screen);
40
+                game(diff, ecran, screen);
41
+                choice = 0;
42
+                break;
43
+            case 2:
44
+                editor(ecran, screen);
45
+                choice = 0;
46
+                break;
47
+        }
48
+    }
49
+    SDL_Quit();
50
+    return EXIT_SUCCESS;
17
 }
51
 }
18
 
52
 

+ 137
- 0
Mario Sokoban/menu.c 파일 보기

1
+//
2
+//  menu.c
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-15.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <SDL2/SDL.h>
12
+#include <SDL2_image/SDL_image.h>
13
+#include "constantes.h"
14
+#include "game.h"
15
+#include "level.h"
16
+
17
+
18
+int menu(SDL_Window *ecran, SDL_Surface *screen)
19
+{
20
+    int choice = 0, running = 1, i = 0, j = 0, target_r = 0;
21
+    int map[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
22
+    SDL_Event event;
23
+    SDL_Surface *mario[4] = {NULL};
24
+    SDL_Surface *wall = NULL, *marioActuel = NULL, *box = NULL, *target = NULL, *boxOK = NULL, *menu = NULL;
25
+    SDL_Rect position, posMario;
26
+    wall = IMG_Load("sprites/mur.jpg");
27
+    box = IMG_Load("sprites/caisse.jpg");
28
+    boxOK = IMG_Load("sprites/caisse_ok.jpg");
29
+    target = IMG_Load("sprites/objectif.png");
30
+    menu = IMG_Load("sprites/menu.png");
31
+    mario[HAUT] = IMG_Load("sprites/mario_haut.gif");
32
+    mario[BAS] = IMG_Load("sprites/mario_bas.gif");
33
+    mario[GAUCHE] = IMG_Load("sprites/mario_gauche.gif");
34
+    mario[DROITE] = IMG_Load("sprites/mario_droite.gif");
35
+    marioActuel = mario[BAS];
36
+    if (loadLevel(0, 0, map) == 0) {
37
+        exit(EXIT_FAILURE);
38
+    }
39
+    for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
40
+    {
41
+        for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
42
+        {
43
+            if (map[i][j] == MARIO)
44
+            {
45
+                posMario.x = i;
46
+                posMario.y = j;
47
+                map[i][j] = VIDE;
48
+            }
49
+        }
50
+    }
51
+    while (running) {
52
+        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
53
+        target_r = 0;
54
+        for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
55
+        {
56
+            for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
57
+            {
58
+                position.x = i * TAILLE_BLOC;
59
+                position.y = j * TAILLE_BLOC;
60
+                
61
+                switch(map[i][j])
62
+                {
63
+                    case WALL:
64
+                        SDL_BlitSurface(wall, NULL, screen, &position);
65
+                        break;
66
+                    case BOX:
67
+                        SDL_BlitSurface(box, NULL, screen, &position);
68
+                        break;
69
+                    case BOX_OK:
70
+                        SDL_BlitSurface(boxOK, NULL, screen, &position);
71
+                        break;
72
+                    case TARGET:
73
+                        SDL_BlitSurface(target, NULL, screen, &position);
74
+                        target_r = 1;
75
+                        break;
76
+                }
77
+            }
78
+        } // Dessine la carte
79
+        position.x = 0;
80
+        position.y = 0;
81
+        SDL_BlitSurface(menu, NULL, screen, &position);
82
+        position.x = posMario.x * TAILLE_BLOC;
83
+        position.y = posMario.y * TAILLE_BLOC;
84
+        SDL_BlitSurface(marioActuel, NULL, screen, &position); // Place le joueur
85
+        SDL_UpdateWindowSurface(ecran);
86
+        if (!target_r) {
87
+            choice = 1;
88
+            running = 0; // Test de victoire
89
+        }
90
+        SDL_WaitEvent(&event);
91
+        switch (event.type){
92
+            case SDL_QUIT:
93
+                exit(EXIT_SUCCESS);
94
+                break;
95
+            case SDL_KEYDOWN:
96
+                switch (event.key.keysym.sym) {
97
+                    case SDLK_ESCAPE:
98
+                        exit(EXIT_SUCCESS);
99
+                        break;
100
+                    case SDLK_1:
101
+                        choice = 1;
102
+                        running = 0;
103
+                        break;
104
+                    case SDLK_2:
105
+                        choice = 2;
106
+                        running = 0;
107
+                        break;
108
+                    case SDLK_UP:
109
+                        marioActuel = mario[HAUT];
110
+                        mooveMario(map, &posMario, HAUT);
111
+                        break;
112
+                    case SDLK_DOWN:
113
+                        marioActuel = mario[BAS];
114
+                        mooveMario(map, &posMario, BAS);
115
+                        break;
116
+                    case SDLK_RIGHT:
117
+                        marioActuel = mario[DROITE];
118
+                        mooveMario(map, &posMario, DROITE);
119
+                        break;
120
+                    case SDLK_LEFT:
121
+                        marioActuel = mario[GAUCHE];
122
+                        mooveMario(map, &posMario, GAUCHE);
123
+                        break;
124
+                }
125
+        }
126
+    } // Wait for action
127
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 139, 111, 71));
128
+    SDL_UpdateWindowSurface(ecran);
129
+    SDL_FreeSurface(wall);
130
+    SDL_FreeSurface(box);
131
+    SDL_FreeSurface(boxOK);
132
+    SDL_FreeSurface(target);
133
+    for (i = 0 ; i < 4 ; i++)
134
+        SDL_FreeSurface(mario[i]); // Libère la mémoire
135
+    return choice;
136
+}
137
+

+ 16
- 0
Mario Sokoban/menu.h 파일 보기

1
+//
2
+//  menu.h
3
+//  Mario Sokoban
4
+//
5
+//  Created by Benoit Sida on 2014-02-15.
6
+//  Copyright (c) 2014 Benoit Sida. All rights reserved.
7
+//
8
+
9
+#ifndef Mario_Sokoban_menu_h
10
+#define Mario_Sokoban_menu_h
11
+
12
+int menu(SDL_Window*, SDL_Surface*);
13
+void mooveMario(int carte[][NB_BLOCS_HAUTEUR], SDL_Rect*, int);
14
+void mooveBox(int*, int*);
15
+
16
+#endif

BIN
Mario Sokoban/sprites/caisse.jpg 파일 보기


BIN
Mario Sokoban/sprites/caisse_ok.jpg 파일 보기


BIN
Mario Sokoban/sprites/commandes.png 파일 보기


BIN
Mario Sokoban/sprites/difficulty.png 파일 보기


BIN
Mario Sokoban/sprites/draw.png 파일 보기


BIN
Mario Sokoban/sprites/mario_bas.gif 파일 보기


BIN
Mario Sokoban/sprites/mario_droite.gif 파일 보기


BIN
Mario Sokoban/sprites/mario_gauche.gif 파일 보기


BIN
Mario Sokoban/sprites/mario_haut.gif 파일 보기


BIN
Mario Sokoban/sprites/menu.png 파일 보기


BIN
Mario Sokoban/sprites/mur.jpg 파일 보기


BIN
Mario Sokoban/sprites/objectif.png 파일 보기


BIN
Mario Sokoban/sprites/win.png 파일 보기