├── .gitattributes
├── .gitignore
├── ClassDiagram.cd
├── EasyXa.lib
├── EasyXw.lib
├── LICENSE
├── add_score.cpp
├── add_score.h
├── brick.cpp
├── brick.h
├── camera.cpp
├── camera.h
├── chestnut.cpp
├── chestnut.h
├── coin.cpp
├── coin.h
├── collider.cpp
├── collider.h
├── death_animation.cpp
├── death_animation.h
├── dirent.h
├── ege.h
├── ege
├── button.h
├── egecontrolbase.h
├── fps.h
├── label.h
└── sys_edit.h
├── flagpole.cpp
├── flagpole.h
├── flower.cpp
├── flower.h
├── freeze_block.cpp
├── freeze_block.h
├── global.cpp
├── global.h
├── graphics.h
├── graphics.txt
├── graphics64.lib
├── headers.cpp
├── headers.h
├── keymsg.cpp
├── keymsg.h
├── level.cpp
├── level.h
├── level_data
├── 1-1.mio
├── 1-2.mio
├── 1-3.mio
└── 1-4.mio
├── load_screen.cpp
├── load_screen.h
├── main.cpp
├── mario.cpp
├── mario.h
├── mario.sln
├── mario.vcxproj
├── mario.vcxproj.filters
├── mario_fire.cpp
├── mario_fire.h
├── menu.cpp
├── menu.h
├── mushroom.cpp
├── mushroom.h
├── musicplayer.cpp
├── musicplayer.h
├── question_block.cpp
├── question_block.h
├── readme.assets
├── image-20211117222718152.png
├── image-20211205123022243.png
├── image-20211205123140803.png
├── image-20220104102845486.png
├── image-20220104103039110.png
├── image-20220104103151073.png
├── image-20220104103348220.png
├── image-20220104103420908.png
├── image-20220104103512409.png
└── image-20220104104303136.png
├── readme.md
├── resources
├── fonts
│ ├── Fixedsys500c.ttf
│ └── __init__.py
├── graphics
│ ├── __init__.py
│ ├── enemies.png
│ ├── id.pptx
│ ├── item_objects.png
│ ├── level_1.png
│ ├── mario_bros.png
│ ├── smb_enemies_sheet.png
│ ├── text_images.png
│ ├── tile_set.png
│ └── title_screen.png
├── music
│ ├── __init__.py
│ ├── course_clear.wav
│ ├── death.wav
│ ├── flagpole.wav
│ ├── game_over.mp3
│ ├── invincible.mp3
│ ├── main_theme.mp3
│ ├── main_theme_sped_up.mp3
│ ├── out_of_time.wav
│ ├── stage_clear.wav
│ ├── start.mp3
│ └── world_clear.wav
└── sound
│ ├── __init__.py
│ ├── begin.wav
│ ├── big_jump.mp3
│ ├── brick_smash.mp3
│ ├── bump.mp3
│ ├── coin.mp3
│ ├── count_down.mp3
│ ├── fireball.mp3
│ ├── kick.mp3
│ ├── main_theme_sped_up.mp3
│ ├── one_up.mp3
│ ├── pipe.mp3
│ ├── powerup.mp3
│ ├── powerup_appears.mp3
│ ├── small_jump.mp3
│ └── stomp.mp3
├── star.cpp
├── star.h
├── tortoise.cpp
└── tortoise.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/ClassDiagram.cd:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/EasyXa.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/EasyXa.lib
--------------------------------------------------------------------------------
/EasyXw.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/EasyXw.lib
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/add_score.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/add_score.cpp
--------------------------------------------------------------------------------
/add_score.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/add_score.h
--------------------------------------------------------------------------------
/brick.cpp:
--------------------------------------------------------------------------------
1 | #include "brick.h"
2 | #include "global.h"
3 |
4 | Brick::Brick(char* s)
5 | {
6 | int a, b;
7 | sscanf(s, "%d%d", &a, &b);
8 | ct = Costume{ 4, a, b };
9 | collider_layer = 1;
10 | id = ++COLLIDER_ID;
11 | freeze = true;
12 | width = 1, height = 1;
13 | name = "brick";
14 | show_layer = 4;
15 | }
16 |
17 | Brick::Brick(int a, int b)
18 | {
19 | ct = Costume{ 4, a, b };
20 | collider_layer = 1;
21 | id = ++COLLIDER_ID;
22 | freeze = true;
23 | width = 1, height = 1;
24 | name = "brick";
25 | }
26 |
27 | bool Brick::update()
28 | {
29 | return false;
30 | }
31 |
32 | std::pair Brick::getctpos()
33 | {
34 | return std::make_pair(sx, sy);
35 | }
36 |
37 | Costume Brick::getcostume()
38 | {
39 | if (!isshow) return Costume{ -1, -1, -1 };
40 | return ct;
41 | }
42 |
43 | bool Brick::report_collision(int direction, Collider* target, int target_collider_layer)
44 | {
45 | return false;
46 | }
--------------------------------------------------------------------------------
/brick.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/brick.h
--------------------------------------------------------------------------------
/camera.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/camera.cpp
--------------------------------------------------------------------------------
/camera.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/camera.h
--------------------------------------------------------------------------------
/chestnut.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/chestnut.cpp
--------------------------------------------------------------------------------
/chestnut.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/chestnut.h
--------------------------------------------------------------------------------
/coin.cpp:
--------------------------------------------------------------------------------
1 | #include "coin.h"
2 | #include "level.h"
3 | #include "musicplayer.h"
4 | Coin::Coin(char* s)
5 | {
6 | freeze = true;
7 | show_layer = 3;
8 | collider_layer = 5;
9 | ct = { 12, 0, 0 };
10 | }
11 |
12 | Costume Coin::getcostume()
13 | {
14 | if (!isshow) return Costume{ -1, -1, -1 };
15 | if (level.now_time - animation_time > 200) {
16 | ct.c = (ct.c + 1) % 3;
17 | animation_time = level.now_time;
18 | }
19 | return ct;
20 | }
21 |
22 | std::pair Coin::getctpos()
23 | {
24 | return std::make_pair(sx, sy);
25 | }
26 |
27 | bool Coin::report_collision(int direction, Collider* target, int target_collider_layer)
28 | {
29 | if (!isrun) return false;
30 | COIN_TOTAL++;
31 | SCORE += 100;
32 | musicplayer.play("sound-coin");
33 | level.remove(this);
34 | return true;
35 | }
--------------------------------------------------------------------------------
/coin.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/coin.h
--------------------------------------------------------------------------------
/collider.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/collider.cpp
--------------------------------------------------------------------------------
/collider.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/collider.h
--------------------------------------------------------------------------------
/death_animation.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/death_animation.cpp
--------------------------------------------------------------------------------
/death_animation.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/death_animation.h
--------------------------------------------------------------------------------
/dirent.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Dirent interface for Microsoft Visual Studio
3 | *
4 | * Copyright (C) 1998-2019 Toni Ronkko
5 | * This file is part of dirent. Dirent may be freely distributed
6 | * under the MIT license. For all details and documentation, see
7 | * https://github.com/tronkko/dirent
8 | */
9 | #ifndef DIRENT_H
10 | #define DIRENT_H
11 |
12 | /* Hide warnings about unreferenced local functions */
13 | #if defined(__clang__)
14 | # pragma clang diagnostic ignored "-Wunused-function"
15 | #elif defined(_MSC_VER)
16 | # pragma warning(disable:4505)
17 | #elif defined(__GNUC__)
18 | # pragma GCC diagnostic ignored "-Wunused-function"
19 | #endif
20 |
21 | /*
22 | * Include windows.h without Windows Sockets 1.1 to prevent conflicts with
23 | * Windows Sockets 2.0.
24 | */
25 | #ifndef WIN32_LEAN_AND_MEAN
26 | # define WIN32_LEAN_AND_MEAN
27 | #endif
28 | #include
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 |
40 | /* Indicates that d_type field is available in dirent structure */
41 | #define _DIRENT_HAVE_D_TYPE
42 |
43 | /* Indicates that d_namlen field is available in dirent structure */
44 | #define _DIRENT_HAVE_D_NAMLEN
45 |
46 | /* Entries missing from MSVC 6.0 */
47 | #if !defined(FILE_ATTRIBUTE_DEVICE)
48 | # define FILE_ATTRIBUTE_DEVICE 0x40
49 | #endif
50 |
51 | /* File type and permission flags for stat(), general mask */
52 | #if !defined(S_IFMT)
53 | # define S_IFMT _S_IFMT
54 | #endif
55 |
56 | /* Directory bit */
57 | #if !defined(S_IFDIR)
58 | # define S_IFDIR _S_IFDIR
59 | #endif
60 |
61 | /* Character device bit */
62 | #if !defined(S_IFCHR)
63 | # define S_IFCHR _S_IFCHR
64 | #endif
65 |
66 | /* Pipe bit */
67 | #if !defined(S_IFFIFO)
68 | # define S_IFFIFO _S_IFFIFO
69 | #endif
70 |
71 | /* Regular file bit */
72 | #if !defined(S_IFREG)
73 | # define S_IFREG _S_IFREG
74 | #endif
75 |
76 | /* Read permission */
77 | #if !defined(S_IREAD)
78 | # define S_IREAD _S_IREAD
79 | #endif
80 |
81 | /* Write permission */
82 | #if !defined(S_IWRITE)
83 | # define S_IWRITE _S_IWRITE
84 | #endif
85 |
86 | /* Execute permission */
87 | #if !defined(S_IEXEC)
88 | # define S_IEXEC _S_IEXEC
89 | #endif
90 |
91 | /* Pipe */
92 | #if !defined(S_IFIFO)
93 | # define S_IFIFO _S_IFIFO
94 | #endif
95 |
96 | /* Block device */
97 | #if !defined(S_IFBLK)
98 | # define S_IFBLK 0
99 | #endif
100 |
101 | /* Link */
102 | #if !defined(S_IFLNK)
103 | # define S_IFLNK 0
104 | #endif
105 |
106 | /* Socket */
107 | #if !defined(S_IFSOCK)
108 | # define S_IFSOCK 0
109 | #endif
110 |
111 | /* Read user permission */
112 | #if !defined(S_IRUSR)
113 | # define S_IRUSR S_IREAD
114 | #endif
115 |
116 | /* Write user permission */
117 | #if !defined(S_IWUSR)
118 | # define S_IWUSR S_IWRITE
119 | #endif
120 |
121 | /* Execute user permission */
122 | #if !defined(S_IXUSR)
123 | # define S_IXUSR 0
124 | #endif
125 |
126 | /* Read group permission */
127 | #if !defined(S_IRGRP)
128 | # define S_IRGRP 0
129 | #endif
130 |
131 | /* Write group permission */
132 | #if !defined(S_IWGRP)
133 | # define S_IWGRP 0
134 | #endif
135 |
136 | /* Execute group permission */
137 | #if !defined(S_IXGRP)
138 | # define S_IXGRP 0
139 | #endif
140 |
141 | /* Read others permission */
142 | #if !defined(S_IROTH)
143 | # define S_IROTH 0
144 | #endif
145 |
146 | /* Write others permission */
147 | #if !defined(S_IWOTH)
148 | # define S_IWOTH 0
149 | #endif
150 |
151 | /* Execute others permission */
152 | #if !defined(S_IXOTH)
153 | # define S_IXOTH 0
154 | #endif
155 |
156 | /* Maximum length of file name */
157 | #if !defined(PATH_MAX)
158 | # define PATH_MAX MAX_PATH
159 | #endif
160 | #if !defined(FILENAME_MAX)
161 | # define FILENAME_MAX MAX_PATH
162 | #endif
163 | #if !defined(NAME_MAX)
164 | # define NAME_MAX FILENAME_MAX
165 | #endif
166 |
167 | /* File type flags for d_type */
168 | #define DT_UNKNOWN 0
169 | #define DT_REG S_IFREG
170 | #define DT_DIR S_IFDIR
171 | #define DT_FIFO S_IFIFO
172 | #define DT_SOCK S_IFSOCK
173 | #define DT_CHR S_IFCHR
174 | #define DT_BLK S_IFBLK
175 | #define DT_LNK S_IFLNK
176 |
177 | /* Macros for converting between st_mode and d_type */
178 | #define IFTODT(mode) ((mode) & S_IFMT)
179 | #define DTTOIF(type) (type)
180 |
181 | /*
182 | * File type macros. Note that block devices, sockets and links cannot be
183 | * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
184 | * only defined for compatibility. These macros should always return false
185 | * on Windows.
186 | */
187 | #if !defined(S_ISFIFO)
188 | # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
189 | #endif
190 | #if !defined(S_ISDIR)
191 | # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
192 | #endif
193 | #if !defined(S_ISREG)
194 | # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
195 | #endif
196 | #if !defined(S_ISLNK)
197 | # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
198 | #endif
199 | #if !defined(S_ISSOCK)
200 | # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
201 | #endif
202 | #if !defined(S_ISCHR)
203 | # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
204 | #endif
205 | #if !defined(S_ISBLK)
206 | # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
207 | #endif
208 |
209 | /* Return the exact length of the file name without zero terminator */
210 | #define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
211 |
212 | /* Return the maximum size of a file name */
213 | #define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1)
214 |
215 |
216 | #ifdef __cplusplus
217 | extern "C" {
218 | #endif
219 |
220 |
221 | /* Wide-character version */
222 | struct _wdirent {
223 | /* Always zero */
224 | long d_ino;
225 |
226 | /* File position within stream */
227 | long d_off;
228 |
229 | /* Structure size */
230 | unsigned short d_reclen;
231 |
232 | /* Length of name without \0 */
233 | size_t d_namlen;
234 |
235 | /* File type */
236 | int d_type;
237 |
238 | /* File name */
239 | wchar_t d_name[PATH_MAX + 1];
240 | };
241 | typedef struct _wdirent _wdirent;
242 |
243 | struct _WDIR {
244 | /* Current directory entry */
245 | struct _wdirent ent;
246 |
247 | /* Private file data */
248 | WIN32_FIND_DATAW data;
249 |
250 | /* True if data is valid */
251 | int cached;
252 |
253 | /* Win32 search handle */
254 | HANDLE handle;
255 |
256 | /* Initial directory name */
257 | wchar_t* patt;
258 | };
259 | typedef struct _WDIR _WDIR;
260 |
261 | /* Multi-byte character version */
262 | struct dirent {
263 | /* Always zero */
264 | long d_ino;
265 |
266 | /* File position within stream */
267 | long d_off;
268 |
269 | /* Structure size */
270 | unsigned short d_reclen;
271 |
272 | /* Length of name without \0 */
273 | size_t d_namlen;
274 |
275 | /* File type */
276 | int d_type;
277 |
278 | /* File name */
279 | char d_name[PATH_MAX + 1];
280 | };
281 | typedef struct dirent dirent;
282 |
283 | struct DIR {
284 | struct dirent ent;
285 | struct _WDIR* wdirp;
286 | };
287 | typedef struct DIR DIR;
288 |
289 |
290 | /* Dirent functions */
291 | static DIR* opendir(const char* dirname);
292 | static _WDIR* _wopendir(const wchar_t* dirname);
293 |
294 | static struct dirent* readdir(DIR* dirp);
295 | static struct _wdirent* _wreaddir(_WDIR* dirp);
296 |
297 | static int readdir_r(
298 | DIR* dirp, struct dirent* entry, struct dirent** result);
299 | static int _wreaddir_r(
300 | _WDIR* dirp, struct _wdirent* entry, struct _wdirent** result);
301 |
302 | static int closedir(DIR* dirp);
303 | static int _wclosedir(_WDIR* dirp);
304 |
305 | static void rewinddir(DIR* dirp);
306 | static void _wrewinddir(_WDIR* dirp);
307 |
308 | static int scandir(const char* dirname, struct dirent*** namelist,
309 | int (*filter)(const struct dirent*),
310 | int (*compare)(const struct dirent**, const struct dirent**));
311 |
312 | static int alphasort(const struct dirent** a, const struct dirent** b);
313 |
314 | static int versionsort(const struct dirent** a, const struct dirent** b);
315 |
316 |
317 | /* For compatibility with Symbian */
318 | #define wdirent _wdirent
319 | #define WDIR _WDIR
320 | #define wopendir _wopendir
321 | #define wreaddir _wreaddir
322 | #define wclosedir _wclosedir
323 | #define wrewinddir _wrewinddir
324 |
325 |
326 | /* Internal utility functions */
327 | static WIN32_FIND_DATAW* dirent_first(_WDIR* dirp);
328 | static WIN32_FIND_DATAW* dirent_next(_WDIR* dirp);
329 |
330 | static int dirent_mbstowcs_s(
331 | size_t* pReturnValue,
332 | wchar_t* wcstr,
333 | size_t sizeInWords,
334 | const char* mbstr,
335 | size_t count);
336 |
337 | static int dirent_wcstombs_s(
338 | size_t* pReturnValue,
339 | char* mbstr,
340 | size_t sizeInBytes,
341 | const wchar_t* wcstr,
342 | size_t count);
343 |
344 | static void dirent_set_errno(int error);
345 |
346 |
347 | /*
348 | * Open directory stream DIRNAME for read and return a pointer to the
349 | * internal working area that is used to retrieve individual directory
350 | * entries.
351 | */
352 | static _WDIR*
353 | _wopendir(
354 | const wchar_t* dirname)
355 | {
356 | _WDIR* dirp;
357 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
358 | /* Desktop */
359 | DWORD n;
360 | #else
361 | /* WinRT */
362 | size_t n;
363 | #endif
364 | wchar_t* p;
365 |
366 | /* Must have directory name */
367 | if (dirname == NULL || dirname[0] == '\0') {
368 | dirent_set_errno(ENOENT);
369 | return NULL;
370 | }
371 |
372 | /* Allocate new _WDIR structure */
373 | dirp = (_WDIR*)malloc(sizeof(struct _WDIR));
374 | if (!dirp) {
375 | return NULL;
376 | }
377 |
378 | /* Reset _WDIR structure */
379 | dirp->handle = INVALID_HANDLE_VALUE;
380 | dirp->patt = NULL;
381 | dirp->cached = 0;
382 |
383 | /*
384 | * Compute the length of full path plus zero terminator
385 | *
386 | * Note that on WinRT there's no way to convert relative paths
387 | * into absolute paths, so just assume it is an absolute path.
388 | */
389 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
390 | /* Desktop */
391 | n = GetFullPathNameW(dirname, 0, NULL, NULL);
392 | #else
393 | /* WinRT */
394 | n = wcslen(dirname);
395 | #endif
396 |
397 | /* Allocate room for absolute directory name and search pattern */
398 | dirp->patt = (wchar_t*)malloc(sizeof(wchar_t) * n + 16);
399 | if (dirp->patt == NULL) {
400 | goto exit_closedir;
401 | }
402 |
403 | /*
404 | * Convert relative directory name to an absolute one. This
405 | * allows rewinddir() to function correctly even when current
406 | * working directory is changed between opendir() and rewinddir().
407 | *
408 | * Note that on WinRT there's no way to convert relative paths
409 | * into absolute paths, so just assume it is an absolute path.
410 | */
411 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
412 | /* Desktop */
413 | n = GetFullPathNameW(dirname, n, dirp->patt, NULL);
414 | if (n <= 0) {
415 | goto exit_closedir;
416 | }
417 | #else
418 | /* WinRT */
419 | wcsncpy_s(dirp->patt, n + 1, dirname, n);
420 | #endif
421 |
422 | /* Append search pattern \* to the directory name */
423 | p = dirp->patt + n;
424 | switch (p[-1]) {
425 | case '\\':
426 | case '/':
427 | case ':':
428 | /* Directory ends in path separator, e.g. c:\temp\ */
429 | /*NOP*/;
430 | break;
431 |
432 | default:
433 | /* Directory name doesn't end in path separator */
434 | *p++ = '\\';
435 | }
436 | *p++ = '*';
437 | *p = '\0';
438 |
439 | /* Open directory stream and retrieve the first entry */
440 | if (!dirent_first(dirp)) {
441 | goto exit_closedir;
442 | }
443 |
444 | /* Success */
445 | return dirp;
446 |
447 | /* Failure */
448 | exit_closedir:
449 | _wclosedir(dirp);
450 | return NULL;
451 | }
452 |
453 | /*
454 | * Read next directory entry.
455 | *
456 | * Returns pointer to static directory entry which may be overwritten by
457 | * subsequent calls to _wreaddir().
458 | */
459 | static struct _wdirent*
460 | _wreaddir(
461 | _WDIR* dirp)
462 | {
463 | struct _wdirent* entry;
464 |
465 | /*
466 | * Read directory entry to buffer. We can safely ignore the return value
467 | * as entry will be set to NULL in case of error.
468 | */
469 | (void)_wreaddir_r(dirp, &dirp->ent, &entry);
470 |
471 | /* Return pointer to statically allocated directory entry */
472 | return entry;
473 | }
474 |
475 | /*
476 | * Read next directory entry.
477 | *
478 | * Returns zero on success. If end of directory stream is reached, then sets
479 | * result to NULL and returns zero.
480 | */
481 | static int
482 | _wreaddir_r(
483 | _WDIR* dirp,
484 | struct _wdirent* entry,
485 | struct _wdirent** result)
486 | {
487 | WIN32_FIND_DATAW* datap;
488 |
489 | /* Read next directory entry */
490 | datap = dirent_next(dirp);
491 | if (datap) {
492 | size_t n;
493 | DWORD attr;
494 |
495 | /*
496 | * Copy file name as wide-character string. If the file name is too
497 | * long to fit in to the destination buffer, then truncate file name
498 | * to PATH_MAX characters and zero-terminate the buffer.
499 | */
500 | n = 0;
501 | while (n < PATH_MAX && datap->cFileName[n] != 0) {
502 | entry->d_name[n] = datap->cFileName[n];
503 | n++;
504 | }
505 | entry->d_name[n] = 0;
506 |
507 | /* Length of file name excluding zero terminator */
508 | entry->d_namlen = n;
509 |
510 | /* File type */
511 | attr = datap->dwFileAttributes;
512 | if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
513 | entry->d_type = DT_CHR;
514 | }
515 | else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
516 | entry->d_type = DT_DIR;
517 | }
518 | else {
519 | entry->d_type = DT_REG;
520 | }
521 |
522 | /* Reset dummy fields */
523 | entry->d_ino = 0;
524 | entry->d_off = 0;
525 | entry->d_reclen = sizeof(struct _wdirent);
526 |
527 | /* Set result address */
528 | *result = entry;
529 |
530 | }
531 | else {
532 |
533 | /* Return NULL to indicate end of directory */
534 | *result = NULL;
535 |
536 | }
537 |
538 | return /*OK*/0;
539 | }
540 |
541 | /*
542 | * Close directory stream opened by opendir() function. This invalidates the
543 | * DIR structure as well as any directory entry read previously by
544 | * _wreaddir().
545 | */
546 | static int
547 | _wclosedir(
548 | _WDIR* dirp)
549 | {
550 | int ok;
551 | if (dirp) {
552 |
553 | /* Release search handle */
554 | if (dirp->handle != INVALID_HANDLE_VALUE) {
555 | FindClose(dirp->handle);
556 | }
557 |
558 | /* Release search pattern */
559 | free(dirp->patt);
560 |
561 | /* Release directory structure */
562 | free(dirp);
563 | ok = /*success*/0;
564 |
565 | }
566 | else {
567 |
568 | /* Invalid directory stream */
569 | dirent_set_errno(EBADF);
570 | ok = /*failure*/-1;
571 |
572 | }
573 | return ok;
574 | }
575 |
576 | /*
577 | * Rewind directory stream such that _wreaddir() returns the very first
578 | * file name again.
579 | */
580 | static void
581 | _wrewinddir(
582 | _WDIR* dirp)
583 | {
584 | if (dirp) {
585 | /* Release existing search handle */
586 | if (dirp->handle != INVALID_HANDLE_VALUE) {
587 | FindClose(dirp->handle);
588 | }
589 |
590 | /* Open new search handle */
591 | dirent_first(dirp);
592 | }
593 | }
594 |
595 | /* Get first directory entry (internal) */
596 | static WIN32_FIND_DATAW*
597 | dirent_first(
598 | _WDIR* dirp)
599 | {
600 | WIN32_FIND_DATAW* datap;
601 | DWORD error;
602 |
603 | /* Open directory and retrieve the first entry */
604 | dirp->handle = FindFirstFileExW(
605 | dirp->patt, FindExInfoStandard, &dirp->data,
606 | FindExSearchNameMatch, NULL, 0);
607 | if (dirp->handle != INVALID_HANDLE_VALUE) {
608 |
609 | /* a directory entry is now waiting in memory */
610 | datap = &dirp->data;
611 | dirp->cached = 1;
612 |
613 | }
614 | else {
615 |
616 | /* Failed to open directory: no directory entry in memory */
617 | dirp->cached = 0;
618 | datap = NULL;
619 |
620 | /* Set error code */
621 | error = GetLastError();
622 | switch (error) {
623 | case ERROR_ACCESS_DENIED:
624 | /* No read access to directory */
625 | dirent_set_errno(EACCES);
626 | break;
627 |
628 | case ERROR_DIRECTORY:
629 | /* Directory name is invalid */
630 | dirent_set_errno(ENOTDIR);
631 | break;
632 |
633 | case ERROR_PATH_NOT_FOUND:
634 | default:
635 | /* Cannot find the file */
636 | dirent_set_errno(ENOENT);
637 | }
638 |
639 | }
640 | return datap;
641 | }
642 |
643 | /*
644 | * Get next directory entry (internal).
645 | *
646 | * Returns
647 | */
648 | static WIN32_FIND_DATAW*
649 | dirent_next(
650 | _WDIR* dirp)
651 | {
652 | WIN32_FIND_DATAW* p;
653 |
654 | /* Get next directory entry */
655 | if (dirp->cached != 0) {
656 |
657 | /* A valid directory entry already in memory */
658 | p = &dirp->data;
659 | dirp->cached = 0;
660 |
661 | }
662 | else if (dirp->handle != INVALID_HANDLE_VALUE) {
663 |
664 | /* Get the next directory entry from stream */
665 | if (FindNextFileW(dirp->handle, &dirp->data) != FALSE) {
666 | /* Got a file */
667 | p = &dirp->data;
668 | }
669 | else {
670 | /* The very last entry has been processed or an error occurred */
671 | FindClose(dirp->handle);
672 | dirp->handle = INVALID_HANDLE_VALUE;
673 | p = NULL;
674 | }
675 |
676 | }
677 | else {
678 |
679 | /* End of directory stream reached */
680 | p = NULL;
681 |
682 | }
683 |
684 | return p;
685 | }
686 |
687 | /*
688 | * Open directory stream using plain old C-string.
689 | */
690 | static DIR*
691 | opendir(
692 | const char* dirname)
693 | {
694 | struct DIR* dirp;
695 |
696 | /* Must have directory name */
697 | if (dirname == NULL || dirname[0] == '\0') {
698 | dirent_set_errno(ENOENT);
699 | return NULL;
700 | }
701 |
702 | /* Allocate memory for DIR structure */
703 | dirp = (DIR*)malloc(sizeof(struct DIR));
704 | if (!dirp) {
705 | return NULL;
706 | }
707 | {
708 | int error;
709 | wchar_t wname[PATH_MAX + 1];
710 | size_t n;
711 |
712 | /* Convert directory name to wide-character string */
713 | error = dirent_mbstowcs_s(
714 | &n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
715 | if (error) {
716 | /*
717 | * Cannot convert file name to wide-character string. This
718 | * occurs if the string contains invalid multi-byte sequences or
719 | * the output buffer is too small to contain the resulting
720 | * string.
721 | */
722 | goto exit_free;
723 | }
724 |
725 |
726 | /* Open directory stream using wide-character name */
727 | dirp->wdirp = _wopendir(wname);
728 | if (!dirp->wdirp) {
729 | goto exit_free;
730 | }
731 |
732 | }
733 |
734 | /* Success */
735 | return dirp;
736 |
737 | /* Failure */
738 | exit_free:
739 | free(dirp);
740 | return NULL;
741 | }
742 |
743 | /*
744 | * Read next directory entry.
745 | */
746 | static struct dirent*
747 | readdir(
748 | DIR* dirp)
749 | {
750 | struct dirent* entry;
751 |
752 | /*
753 | * Read directory entry to buffer. We can safely ignore the return value
754 | * as entry will be set to NULL in case of error.
755 | */
756 | (void)readdir_r(dirp, &dirp->ent, &entry);
757 |
758 | /* Return pointer to statically allocated directory entry */
759 | return entry;
760 | }
761 |
762 | /*
763 | * Read next directory entry into called-allocated buffer.
764 | *
765 | * Returns zero on success. If the end of directory stream is reached, then
766 | * sets result to NULL and returns zero.
767 | */
768 | static int
769 | readdir_r(
770 | DIR* dirp,
771 | struct dirent* entry,
772 | struct dirent** result)
773 | {
774 | WIN32_FIND_DATAW* datap;
775 |
776 | /* Read next directory entry */
777 | datap = dirent_next(dirp->wdirp);
778 | if (datap) {
779 | size_t n;
780 | int error;
781 |
782 | /* Attempt to convert file name to multi-byte string */
783 | error = dirent_wcstombs_s(
784 | &n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
785 |
786 | /*
787 | * If the file name cannot be represented by a multi-byte string,
788 | * then attempt to use old 8+3 file name. This allows traditional
789 | * Unix-code to access some file names despite of unicode
790 | * characters, although file names may seem unfamiliar to the user.
791 | *
792 | * Be ware that the code below cannot come up with a short file
793 | * name unless the file system provides one. At least
794 | * VirtualBox shared folders fail to do this.
795 | */
796 | if (error && datap->cAlternateFileName[0] != '\0') {
797 | error = dirent_wcstombs_s(
798 | &n, entry->d_name, PATH_MAX + 1,
799 | datap->cAlternateFileName, PATH_MAX + 1);
800 | }
801 |
802 | if (!error) {
803 | DWORD attr;
804 |
805 | /* Length of file name excluding zero terminator */
806 | entry->d_namlen = n - 1;
807 |
808 | /* File attributes */
809 | attr = datap->dwFileAttributes;
810 | if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
811 | entry->d_type = DT_CHR;
812 | }
813 | else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
814 | entry->d_type = DT_DIR;
815 | }
816 | else {
817 | entry->d_type = DT_REG;
818 | }
819 |
820 | /* Reset dummy fields */
821 | entry->d_ino = 0;
822 | entry->d_off = 0;
823 | entry->d_reclen = sizeof(struct dirent);
824 |
825 | }
826 | else {
827 |
828 | /*
829 | * Cannot convert file name to multi-byte string so construct
830 | * an erroneous directory entry and return that. Note that
831 | * we cannot return NULL as that would stop the processing
832 | * of directory entries completely.
833 | */
834 | entry->d_name[0] = '?';
835 | entry->d_name[1] = '\0';
836 | entry->d_namlen = 1;
837 | entry->d_type = DT_UNKNOWN;
838 | entry->d_ino = 0;
839 | entry->d_off = -1;
840 | entry->d_reclen = 0;
841 |
842 | }
843 |
844 | /* Return pointer to directory entry */
845 | *result = entry;
846 |
847 | }
848 | else {
849 |
850 | /* No more directory entries */
851 | *result = NULL;
852 |
853 | }
854 |
855 | return /*OK*/0;
856 | }
857 |
858 | /*
859 | * Close directory stream.
860 | */
861 | static int
862 | closedir(
863 | DIR* dirp)
864 | {
865 | int ok;
866 | if (dirp) {
867 |
868 | /* Close wide-character directory stream */
869 | ok = _wclosedir(dirp->wdirp);
870 | dirp->wdirp = NULL;
871 |
872 | /* Release multi-byte character version */
873 | free(dirp);
874 |
875 | }
876 | else {
877 |
878 | /* Invalid directory stream */
879 | dirent_set_errno(EBADF);
880 | ok = /*failure*/-1;
881 |
882 | }
883 | return ok;
884 | }
885 |
886 | /*
887 | * Rewind directory stream to beginning.
888 | */
889 | static void
890 | rewinddir(
891 | DIR* dirp)
892 | {
893 | /* Rewind wide-character string directory stream */
894 | _wrewinddir(dirp->wdirp);
895 | }
896 |
897 | /*
898 | * Scan directory for entries.
899 | */
900 | static int
901 | scandir(
902 | const char* dirname,
903 | struct dirent*** namelist,
904 | int (*filter)(const struct dirent*),
905 | int (*compare)(const struct dirent**, const struct dirent**))
906 | {
907 | struct dirent** files = NULL;
908 | size_t size = 0;
909 | size_t allocated = 0;
910 | const size_t init_size = 1;
911 | DIR* dir = NULL;
912 | struct dirent* entry;
913 | struct dirent* tmp = NULL;
914 | size_t i;
915 | int result = 0;
916 |
917 | /* Open directory stream */
918 | dir = opendir(dirname);
919 | if (dir) {
920 |
921 | /* Read directory entries to memory */
922 | while (1) {
923 |
924 | /* Enlarge pointer table to make room for another pointer */
925 | if (size >= allocated) {
926 | void* p;
927 | size_t num_entries;
928 |
929 | /* Compute number of entries in the enlarged pointer table */
930 | if (size < init_size) {
931 | /* Allocate initial pointer table */
932 | num_entries = init_size;
933 | }
934 | else {
935 | /* Double the size */
936 | num_entries = size * 2;
937 | }
938 |
939 | /* Allocate first pointer table or enlarge existing table */
940 | p = realloc(files, sizeof(void*) * num_entries);
941 | if (p != NULL) {
942 | /* Got the memory */
943 | files = (dirent**)p;
944 | allocated = num_entries;
945 | }
946 | else {
947 | /* Out of memory */
948 | result = -1;
949 | break;
950 | }
951 |
952 | }
953 |
954 | /* Allocate room for temporary directory entry */
955 | if (tmp == NULL) {
956 | tmp = (struct dirent*)malloc(sizeof(struct dirent));
957 | if (tmp == NULL) {
958 | /* Cannot allocate temporary directory entry */
959 | result = -1;
960 | break;
961 | }
962 | }
963 |
964 | /* Read directory entry to temporary area */
965 | if (readdir_r(dir, tmp, &entry) == /*OK*/0) {
966 |
967 | /* Did we get an entry? */
968 | if (entry != NULL) {
969 | int pass;
970 |
971 | /* Determine whether to include the entry in result */
972 | if (filter) {
973 | /* Let the filter function decide */
974 | pass = filter(tmp);
975 | }
976 | else {
977 | /* No filter function, include everything */
978 | pass = 1;
979 | }
980 |
981 | if (pass) {
982 | /* Store the temporary entry to pointer table */
983 | files[size++] = tmp;
984 | tmp = NULL;
985 |
986 | /* Keep up with the number of files */
987 | result++;
988 | }
989 |
990 | }
991 | else {
992 |
993 | /*
994 | * End of directory stream reached => sort entries and
995 | * exit.
996 | */
997 | qsort(files, size, sizeof(void*),
998 | (int (*) (const void*, const void*)) compare);
999 | break;
1000 |
1001 | }
1002 |
1003 | }
1004 | else {
1005 | /* Error reading directory entry */
1006 | result = /*Error*/ -1;
1007 | break;
1008 | }
1009 |
1010 | }
1011 |
1012 | }
1013 | else {
1014 | /* Cannot open directory */
1015 | result = /*Error*/ -1;
1016 | }
1017 |
1018 | /* Release temporary directory entry */
1019 | free(tmp);
1020 |
1021 | /* Release allocated memory on error */
1022 | if (result < 0) {
1023 | for (i = 0; i < size; i++) {
1024 | free(files[i]);
1025 | }
1026 | free(files);
1027 | files = NULL;
1028 | }
1029 |
1030 | /* Close directory stream */
1031 | if (dir) {
1032 | closedir(dir);
1033 | }
1034 |
1035 | /* Pass pointer table to caller */
1036 | if (namelist) {
1037 | *namelist = files;
1038 | }
1039 | return result;
1040 | }
1041 |
1042 | /* Alphabetical sorting */
1043 | static int
1044 | alphasort(
1045 | const struct dirent** a, const struct dirent** b)
1046 | {
1047 | return strcoll((*a)->d_name, (*b)->d_name);
1048 | }
1049 |
1050 | /* Sort versions */
1051 | static int
1052 | versionsort(
1053 | const struct dirent** a, const struct dirent** b)
1054 | {
1055 | /* FIXME: implement strverscmp and use that */
1056 | return alphasort(a, b);
1057 | }
1058 |
1059 | /* Convert multi-byte string to wide character string */
1060 | static int
1061 | dirent_mbstowcs_s(
1062 | size_t* pReturnValue,
1063 | wchar_t* wcstr,
1064 | size_t sizeInWords,
1065 | const char* mbstr,
1066 | size_t count)
1067 | {
1068 | int error;
1069 |
1070 | #if defined(_MSC_VER) && _MSC_VER >= 1400
1071 |
1072 | /* Microsoft Visual Studio 2005 or later */
1073 | error = mbstowcs_s(pReturnValue, wcstr, sizeInWords, mbstr, count);
1074 |
1075 | #else
1076 |
1077 | /* Older Visual Studio or non-Microsoft compiler */
1078 | size_t n;
1079 |
1080 | /* Convert to wide-character string (or count characters) */
1081 | n = mbstowcs(wcstr, mbstr, sizeInWords);
1082 | if (!wcstr || n < count) {
1083 |
1084 | /* Zero-terminate output buffer */
1085 | if (wcstr && sizeInWords) {
1086 | if (n >= sizeInWords) {
1087 | n = sizeInWords - 1;
1088 | }
1089 | wcstr[n] = 0;
1090 | }
1091 |
1092 | /* Length of resulting multi-byte string WITH zero terminator */
1093 | if (pReturnValue) {
1094 | *pReturnValue = n + 1;
1095 | }
1096 |
1097 | /* Success */
1098 | error = 0;
1099 |
1100 | }
1101 | else {
1102 |
1103 | /* Could not convert string */
1104 | error = 1;
1105 |
1106 | }
1107 |
1108 | #endif
1109 | return error;
1110 | }
1111 |
1112 | /* Convert wide-character string to multi-byte string */
1113 | static int
1114 | dirent_wcstombs_s(
1115 | size_t* pReturnValue,
1116 | char* mbstr,
1117 | size_t sizeInBytes, /* max size of mbstr */
1118 | const wchar_t* wcstr,
1119 | size_t count)
1120 | {
1121 | int error;
1122 |
1123 | #if defined(_MSC_VER) && _MSC_VER >= 1400
1124 |
1125 | /* Microsoft Visual Studio 2005 or later */
1126 | error = wcstombs_s(pReturnValue, mbstr, sizeInBytes, wcstr, count);
1127 |
1128 | #else
1129 |
1130 | /* Older Visual Studio or non-Microsoft compiler */
1131 | size_t n;
1132 |
1133 | /* Convert to multi-byte string (or count the number of bytes needed) */
1134 | n = wcstombs(mbstr, wcstr, sizeInBytes);
1135 | if (!mbstr || n < count) {
1136 |
1137 | /* Zero-terminate output buffer */
1138 | if (mbstr && sizeInBytes) {
1139 | if (n >= sizeInBytes) {
1140 | n = sizeInBytes - 1;
1141 | }
1142 | mbstr[n] = '\0';
1143 | }
1144 |
1145 | /* Length of resulting multi-bytes string WITH zero-terminator */
1146 | if (pReturnValue) {
1147 | *pReturnValue = n + 1;
1148 | }
1149 |
1150 | /* Success */
1151 | error = 0;
1152 |
1153 | }
1154 | else {
1155 |
1156 | /* Cannot convert string */
1157 | error = 1;
1158 |
1159 | }
1160 |
1161 | #endif
1162 | return error;
1163 | }
1164 |
1165 | /* Set errno variable */
1166 | static void
1167 | dirent_set_errno(
1168 | int error)
1169 | {
1170 | #if defined(_MSC_VER) && _MSC_VER >= 1400
1171 |
1172 | /* Microsoft Visual Studio 2005 and later */
1173 | _set_errno(error);
1174 |
1175 | #else
1176 |
1177 | /* Non-Microsoft compiler or older Microsoft compiler */
1178 | errno = error;
1179 |
1180 | #endif
1181 | }
1182 |
1183 |
1184 | #ifdef __cplusplus
1185 | }
1186 | #endif
1187 | #endif /*DIRENT_H*/
1188 |
1189 |
--------------------------------------------------------------------------------
/ege.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/ege.h
--------------------------------------------------------------------------------
/ege/button.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file button.h
3 | * @brief the EGE control:button
4 | * @author StudyC.cn@gmail.com
5 | * @date 2011-08-09
6 | */
7 | #ifndef _EGE_BUTTON_H_
8 | #define _EGE_BUTTON_H_
9 |
10 | #ifndef _EGE_H_
11 | #error include "button.h" must after include "ege.h" or "graphics.h"
12 | #endif
13 |
14 | #include "egecontrolbase.h"
15 |
16 | #include
17 |
18 | #ifdef DEBUG
19 | #include "ege/label.h"
20 | #else
21 | #define logout(msg)
22 | #endif
23 |
24 | /**
25 | * @brief 按钮控件
26 | */
27 | class button : public egeControlBase
28 | {
29 | public:
30 | //overrides
31 | // 屏幕更新后会被调用,用于更新逻辑
32 | // 以下虚函数都不要直接相互调用
33 | // 以下函数如果返回非0则不向子控件传递键盘鼠标消息
34 | /**
35 | * @brief 响应空格与回车的按下
36 | *
37 | * @param key
38 | * @param flag
39 | *
40 | * @return 0
41 | */
42 | virtual int onKeyDown(int key, int flag) {
43 | if((key==13)||(key==32)){
44 | _pushed=true;
45 | redraw();
46 | }
47 | return 0;
48 | }
49 | /**
50 | * @brief 响应空格与回车的弹起
51 | *
52 | * @param key
53 | * @param flag
54 | *
55 | * @return 0
56 | */
57 | virtual int onKeyUp(int key, int flag) {
58 | if(((key==13)||(key==32))&&_pushed){
59 | if(_on_click){
60 | if(!_on_click(callback_param)){
61 | onClick();
62 | }
63 | }else{
64 | onClick();
65 | }
66 | }
67 | _pushed=false;
68 | redraw();
69 | return 0;
70 | }
71 |
72 | /**
73 | * @brief 响应鼠标左键点击
74 | *
75 | * @param x
76 | * @param y
77 | * @param flag
78 | *
79 | * @return 0
80 | */
81 | virtual int onMouse(int x, int y, int flag) {
82 | if((flag&mouse_flag_left)&&(flag&mouse_msg_down)){
83 | capmouse(true);
84 | _pushed=true;
85 | redraw();
86 | }else if((flag&mouse_flag_left)&&(flag&mouse_msg_up)){
87 | if(_pushed){
88 | if(_on_click){
89 | if(!_on_click(callback_param)){
90 | onClick();
91 | }
92 | }else{
93 | onClick();
94 | }
95 | capmouse(false);
96 | _pushed=false;
97 | }
98 | redraw();
99 | }
100 | return 0;
101 | }
102 | /**
103 | * @brief 屏幕更新后会被调用,用于更新逻辑
104 | *
105 | * @return 0
106 | */
107 | virtual int onUpdate() {
108 | return 0;
109 | }
110 | /**
111 | * @brief 在要获得焦点时调用,返回值一般返回0表示获取键盘输入焦点,返回非0放弃获得输入焦点
112 | *
113 | * @return 0
114 | */
115 | virtual int onGetFocus() {
116 | return 0;
117 | }
118 | /**
119 | * @brief 失去输入焦点时调用
120 | */
121 | virtual void onLostFocus() {
122 | _pushed=false;
123 | redraw();
124 | }
125 | // 设置尺寸前调用,自定义修正函数
126 | virtual void onSizing(int *w, int *h) {
127 | //egeControlBase::onSizing(w,h);
128 | }
129 | // 响应尺寸变化函数
130 | virtual void onSize(int w, int h) {
131 | //egeControlBase::onSize(w,h);
132 | updatesidewidth();
133 | redraw();
134 | }
135 | // 重绘函数,尽量请画到pimg上,以便能控制绘画目标
136 | virtual void onDraw(PIMAGE pimg) const {
137 | }
138 | // 尺寸变化时调用,用于重画过滤缓冲区内容
139 | virtual void onResetFilter() {
140 | }
141 | //virtual void onAddChild(egeControlBase* pChild) {}
142 | //virtual void onDelChild(egeControlBase* pChild) {}
143 | //virtual void onIdle() {} // 保留接口,未用
144 | // 这里以上的函数可以自行定义(注意声明要一致,不要漏掉OnDraw里的const)
145 | //init
146 | CTL_PREINIT(button, egeControlBase) {
147 | // do sth. before sub objects' construct function call
148 | } CTL_PREINITEND;
149 | button(CTL_DEFPARAM) : CTL_INITBASE(egeControlBase) {
150 | CTL_INIT; // must be the first line
151 | size(64, 32);
152 | _font_height = 12;
153 | strcpy(_face, "宋体");
154 | _line_color=BLACK;
155 | _bg_color=RGB(100,100,100);
156 | _text_color=BLACK;
157 | _shadow_color=RGB(50,50,50);
158 | updatesidewidth();
159 |
160 | _on_click=NULL;
161 | callback_param=NULL;
162 | _pushed=false;
163 | _alpha=0xff;
164 | #ifdef DEBUG
165 | _logger=NULL;
166 | #endif
167 | //redraw();
168 | //blendmode(true);
169 | }
170 | //member functions
171 | /**
172 | * @brief 在回调函数指针为NULL或回调函数返回0时被调用
173 | */
174 | virtual void onClick(){
175 | }
176 | /**
177 | * @brief 重绘控件
178 | */
179 | virtual void redraw() const {
180 | PushTarget targer(buf());
181 | setbkcolor_f(RED);
182 | setcolor(RED);
183 | cleardevice();
184 | setbkmode(TRANSPARENT);
185 | setfillstyle(_bg_color,SOLID_FILL);
186 | bar(0, 0, getw()-1, geth()-1);
187 | setfont(_font_height, 0, _face);
188 | setcolor(_text_color);
189 |
190 | //settextjustify(LEFT_TEXT,CENTER_TEXT);
191 | //outtextrect(_side_width, _side_width, getw()-_side_width, geth()-_side_width, _caption);
192 | //outtextrect(0, 0, getw(), geth(), _caption);
193 | int x=(getw()-textwidth(_caption))/2;
194 | int y=(geth()-textheight(_caption))/2;
195 | outtextxy(x,y,_caption);
196 | setbkcolor(_line_color);
197 | rectangle(0,0,getw(),geth());
198 | rectangle(_side_width,_side_width,getw()-_side_width,geth()-_side_width);
199 | setfillstyle(_shadow_color,SOLID_FILL);
200 | if(_pushed){
201 | int points[12]={
202 | 0,0,
203 | getw()-1,0,
204 | getw()-_side_width, _side_width-1,
205 | _side_width-1,_side_width-1,
206 | _side_width-1, geth()-_side_width-1,
207 | 0,geth()-1,
208 | };
209 | fillpoly(6,points);
210 | }else{
211 | int points[12]={
212 | 0,geth()-1,
213 | _side_width-1,geth()-_side_width,
214 | getw()-_side_width, geth()-_side_width,
215 | getw()-_side_width, _side_width-1,
216 | getw()-1,0,
217 | getw()-1,geth()-1,
218 | };
219 | fillpoly(6,points);
220 | }
221 | line(getw()-_side_width, _side_width, getw(), 0);
222 | line(_side_width-1, geth()-_side_width, 0, geth());
223 | //line(getw()-_side_width, geth()-_side_width, getw(), geth());
224 | //line(0,0, _side_width, _side_width);
225 | setbkcolor_f(RGB(_alpha, _alpha, _alpha), filter());
226 | cleardevice(filter());
227 | }
228 | //attributes
229 | /**
230 | * @brief 设置alpha值
231 | *
232 | * @param alpha 0x00 - 0xff
233 | */
234 | void alpha(int alpha){
235 | if(alpha<0){
236 | _alpha=0;
237 | }else if(alpha>0xff){
238 | _alpha=0xff;
239 | }else{
240 | _alpha=alpha;
241 | }
242 | if(_alpha<0xff){
243 | blendmode(true);
244 | }else{
245 | blendmode(false);
246 | }
247 |
248 | }
249 | /**
250 | * @brief 返回alpha值
251 | *
252 | * @return alpha
253 | */
254 | int alpha() const{
255 | return _alpha;
256 | }
257 | /**
258 | * @brief 设置背景色
259 | *
260 | * @param color 背景色
261 | */
262 | void bgcolor(COLORREF color){
263 | _bg_color=color;
264 | redraw();
265 | }
266 | /**
267 | * @brief 返回背景色
268 | *
269 | * @return 背景色
270 | */
271 | COLORREF bgcolor() const{
272 | return _bg_color;
273 | }
274 | /**
275 | * @brief 设置按钮点击回调函数
276 | *
277 | * @param fun 回调函数指针,当且仅当返回值为0时会自动调用onClick
278 | * @param param 附加参数,将会原样传递给回调函数
279 | */
280 | void callback(int (*fun)(void*),void* param){
281 | callback_param=param;
282 | _on_click=fun;
283 | redraw();
284 | }
285 | /**
286 | * @brief 返回回调函数指针
287 | *
288 | * @return 回调函数指针;若未设置,返回NULL
289 | */
290 | template
291 | T callback() const{
292 | return _on_click;
293 | }
294 | /**
295 | * @brief 设置文本
296 | *
297 | * @param text 文本
298 | */
299 | void caption(const char* text) {
300 | strcpy(_caption, text);
301 | redraw();
302 | }
303 | /**
304 | * @brief 返回文本
305 | *
306 | * @return 文本
307 | */
308 | const char* caption() const{
309 | return _caption;
310 | //redraw();
311 | }
312 | /**
313 | * @brief 设置字体
314 | *
315 | * @param fontface 字体名
316 | */
317 | void font(const char* fontface) {
318 | strcpy(_face, fontface);
319 | redraw();
320 | }
321 | /**
322 | * @brief 返回字体
323 | *
324 | * @return 字体名
325 | */
326 | const char* font() const{
327 | return _face;
328 | //redraw();
329 | }
330 | /**
331 | * @brief 设置字体尺寸,待续
332 | *
333 | * @param height
334 | */
335 | void fontsize(int height) {
336 | _font_height = height;
337 | redraw();
338 | }
339 | /**
340 | * @brief 返回字体尺寸
341 | *
342 | * @return 字体尺寸
343 | */
344 | int fontsize() const{
345 | return _font_height;
346 | }
347 | /**
348 | * @brief 设置按钮的线条颜色
349 | *
350 | * @param color 颜色
351 | */
352 | void linecolor(COLORREF color){
353 | _line_color=color;
354 | redraw();
355 | }
356 | /**
357 | * @brief 返回按钮线条颜色
358 | *
359 | * @return 线条颜色
360 | */
361 | COLORREF linecolor() const{
362 | return _line_color;
363 | }
364 | #ifdef DEBUG
365 | /**
366 | * @brief 设置调试信息出口
367 | *
368 | * @param logger
369 | */
370 | void logger(label* logger){
371 | _logger=logger;
372 | }
373 | /**
374 | * @brief 返回调试信息出口
375 | *
376 | * @return
377 | */
378 | label* logger() const{
379 | return _logger;
380 | }
381 | #endif
382 | /**
383 | * @brief 设置阴影颜色
384 | *
385 | * @param color 阴影颜色
386 | */
387 | void shadowcolor(COLORREF color){
388 | _shadow_color=color;
389 | redraw();
390 | }
391 | /**
392 | * @brief 返回阴影颜色
393 | *
394 | * @return 阴影颜色
395 | */
396 | COLORREF shadowcolor() const{
397 | return _shadow_color;
398 | }
399 | /**
400 | * @brief 设置文本颜色
401 | *
402 | * @param color 文本颜色
403 | */
404 | void textcolor(COLORREF color){
405 | _text_color=color;
406 | redraw();
407 | }
408 | /**
409 | * @brief 返回文本颜色
410 | *
411 | * @return 文本颜色
412 | */
413 | COLORREF textcolor() const{
414 | return _text_color;
415 | }
416 | protected:
417 | /**
418 | * @brief 修正边的宽度
419 | */
420 | void updatesidewidth(){
421 | _side_width=std::min(geth(),getw())*0.2;
422 | }
423 | #ifdef DEBUG
424 | /**
425 | * @brief 输出调试信息
426 | *
427 | * @param msg 调试信息文本
428 | */
429 | void logout(const char* msg){
430 | if(_logger){
431 | _logger->setcaption(msg);
432 | }
433 | }
434 | #endif
435 | bool _pushed;
436 | int (*_on_click)(void*);
437 | char _caption[1024];
438 | char _face[32];
439 | COLORREF _line_color;
440 | COLORREF _bg_color;
441 | COLORREF _text_color;
442 | COLORREF _shadow_color;
443 | int _side_width;
444 | int _font_height;
445 | int _alpha;
446 | void* callback_param;
447 | #ifdef DEBUG
448 | label* _logger;
449 | #endif
450 | };
451 |
452 | #endif /* _EGE_BUTTON_H_ */
453 |
--------------------------------------------------------------------------------
/ege/egecontrolbase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/ege/egecontrolbase.h
--------------------------------------------------------------------------------
/ege/fps.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/ege/fps.h
--------------------------------------------------------------------------------
/ege/label.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/ege/label.h
--------------------------------------------------------------------------------
/ege/sys_edit.h:
--------------------------------------------------------------------------------
1 | #ifndef _EGE_SYS_EDIT_H_
2 | #define _EGE_SYS_EDIT_H_
3 |
4 | #ifndef _EGE_H_
5 | #error include "sys_edit.h" must after include "ege.h" or "graphics.h"
6 | #endif
7 |
8 | #include "egecontrolbase.h"
9 |
10 | namespace ege {
11 |
12 | class sys_edit : public egeControlBase
13 | {
14 | public:
15 | CTL_PREINIT(sys_edit, egeControlBase) {
16 | // do sth. before sub objects' construct function call
17 | } CTL_PREINITEND;
18 | sys_edit(CTL_DEFPARAM) : CTL_INITBASE(egeControlBase) {
19 | CTL_INIT; // must be the first linef
20 | directdraw(true);
21 | m_hwnd = NULL;
22 | }
23 | ~sys_edit() {
24 | destroy();
25 | }
26 | int create(bool multiline = false, int scrollbar = 2) {
27 | if (m_hwnd) {
28 | destroy();
29 | }
30 | msg_createwindow msg = {NULL};
31 | msg.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
32 | msg.classname = L"EDIT";
33 | msg.id = egeControlBase::allocId();
34 | msg.style = WS_CHILD | WS_BORDER |
35 | ES_LEFT | ES_WANTRETURN;
36 | if (multiline) {
37 | msg.style |= ES_MULTILINE | WS_VSCROLL;
38 | } else {
39 | msg.style |= ES_AUTOHSCROLL;
40 | }
41 | msg.exstyle = WS_EX_CLIENTEDGE;// | WS_EX_STATICEDGE;
42 | msg.param = this;
43 |
44 | ::PostMessageW(getHWnd(), WM_USER + 1, 1, (LPARAM)&msg);
45 | ::WaitForSingleObject(msg.hEvent, INFINITE);
46 |
47 | m_hwnd = msg.hwnd;
48 | m_hFont = NULL;
49 | m_hBrush = NULL;
50 | m_color = 0x0;
51 | m_bgcolor = 0xFFFFFF;
52 |
53 | ::SetWindowLongPtrW(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
54 | m_callback = ::GetWindowLongPtrW(m_hwnd, GWLP_WNDPROC);
55 | ::SetWindowLongPtrW(m_hwnd, GWLP_WNDPROC, (LONG_PTR)getProcfunc());
56 | {
57 | char fontname[] = {'\xcb', '\xce', '\xcc', '\xe5', 0, 0};
58 | setfont(12, 6, fontname);
59 | }
60 | visible(false);
61 |
62 | ::CloseHandle(msg.hEvent);
63 |
64 | return 0;
65 | }
66 | int destroy() {
67 | if (m_hwnd) {
68 | msg_createwindow msg = {NULL};
69 | msg.hwnd = m_hwnd;
70 | msg.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
71 | ::SendMessage(m_hwnd, WM_SETFONT, 0, 0);
72 | ::DeleteObject(m_hFont);
73 | ::PostMessageW(getHWnd(), WM_USER + 1, 0, (LPARAM)&msg);
74 | ::WaitForSingleObject(msg.hEvent, INFINITE);
75 | ::CloseHandle(msg.hEvent);
76 | if (m_hBrush) ::DeleteObject(m_hBrush);
77 | m_hwnd = NULL;
78 | return 1;
79 | }
80 | return 0;
81 | }
82 | LRESULT onMessage(UINT message, WPARAM wParam, LPARAM lParam);
83 | void visible(bool bvisible) {
84 | egeControlBase::visible(bvisible);
85 | ::ShowWindow(m_hwnd, (int)bvisible);
86 | }
87 | void setfont(int h, int w, LPCSTR fontface) {
88 | {
89 | LOGFONTA lf = {0};
90 | lf.lfHeight = h;
91 | lf.lfWidth = w;
92 | lf.lfEscapement = 0;
93 | lf.lfOrientation = 0;
94 | lf.lfWeight = FW_DONTCARE;
95 | lf.lfItalic = 0;
96 | lf.lfUnderline = 0;
97 | lf.lfStrikeOut = 0;
98 | lf.lfCharSet = DEFAULT_CHARSET;
99 | lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
100 | lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
101 | lf.lfQuality = DEFAULT_QUALITY;
102 | lf.lfPitchAndFamily = DEFAULT_PITCH;
103 | lstrcpyA(lf.lfFaceName, fontface);
104 | HFONT hFont = CreateFontIndirectA(&lf);
105 | if (hFont) {
106 | ::SendMessageA(m_hwnd, WM_SETFONT, (WPARAM)hFont, 0);
107 | ::DeleteObject(m_hFont);
108 | m_hFont = hFont;
109 | }
110 | }
111 | }
112 | void setfont(int h, int w, LPCWSTR fontface) {
113 | {
114 | LOGFONTW lf = {0};
115 | lf.lfHeight = h;
116 | lf.lfWidth = w;
117 | lf.lfEscapement = 0;
118 | lf.lfOrientation = 0;
119 | lf.lfWeight = FW_DONTCARE;
120 | lf.lfItalic = 0;
121 | lf.lfUnderline = 0;
122 | lf.lfStrikeOut = 0;
123 | lf.lfCharSet = DEFAULT_CHARSET;
124 | lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
125 | lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
126 | lf.lfQuality = DEFAULT_QUALITY;
127 | lf.lfPitchAndFamily = DEFAULT_PITCH;
128 | lstrcpyW(lf.lfFaceName, fontface);
129 | HFONT hFont = CreateFontIndirectW(&lf);
130 | if (hFont) {
131 | ::SendMessageW(m_hwnd, WM_SETFONT, (WPARAM)hFont, 0);
132 | ::DeleteObject(m_hFont);
133 | m_hFont = hFont;
134 | }
135 | }
136 | }
137 | void move(int x, int y) {
138 | egeControlBase::move(x, y);
139 | ::MoveWindow(m_hwnd, m_x, m_y, m_w, m_h, TRUE);
140 | }
141 | void size(int w, int h) {
142 | egeControlBase::size(w, h);
143 | ::MoveWindow(m_hwnd, m_x, m_y, m_w, m_h, TRUE);
144 | }
145 | void settext(LPCSTR text) {
146 | ::SendMessageA(m_hwnd, WM_SETTEXT, 0, (LPARAM)text);
147 | }
148 | void settext(LPCWSTR text) {
149 | ::SendMessageW(m_hwnd, WM_SETTEXT, 0, (LPARAM)text);
150 | }
151 | void gettext(int maxlen, LPSTR text) {
152 | ::SendMessageA(m_hwnd, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)text);
153 | }
154 | void gettext(int maxlen, LPWSTR text) {
155 | ::SendMessageW(m_hwnd, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)text);
156 | }
157 | void setmaxlen(int maxlen) {
158 | ::SendMessageW(m_hwnd, EM_LIMITTEXT, (WPARAM)maxlen, 0);
159 | }
160 | void setcolor(color_t color) {
161 | m_color = color;
162 | ::InvalidateRect(m_hwnd, NULL, TRUE);
163 | }
164 | void setbgcolor(color_t bgcolor) {
165 | m_bgcolor = bgcolor;
166 | //::RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE);
167 | ::InvalidateRect(m_hwnd, NULL, TRUE);
168 | }
169 | void setreadonly(bool readonly) {
170 | ::SendMessageW(m_hwnd, EM_SETREADONLY, (WPARAM)readonly, 0);
171 | ::InvalidateRect(m_hwnd, NULL, TRUE);
172 | }
173 | void setfocus() {
174 | ::PostMessageW(getHWnd(), WM_USER + 2, 0, (LPARAM)m_hwnd);
175 | }
176 | protected:
177 | HWND m_hwnd;
178 | HFONT m_hFont;
179 | HBRUSH m_hBrush;
180 | color_t m_color;
181 | color_t m_bgcolor;
182 | LONG_PTR m_callback;
183 | };
184 |
185 | } // namespace ege
186 | #endif /*_EGE_SYS_EDIT_H_*/
187 |
--------------------------------------------------------------------------------
/flagpole.cpp:
--------------------------------------------------------------------------------
1 | #include "flagpole.h"
2 | #include "level.h"
3 | Flagpole::Flagpole()
4 | {
5 | collider_layer = 3;
6 | id = ++COLLIDER_ID;
7 | freeze = true;
8 | width = 0.125, height = 9.5;
9 | name = "flagpole";
10 | x = level.map_range - 9.5, y = 8.25 - 1;
11 | sx = -0.125;
12 | show_layer = 0;
13 | }
14 |
15 | bool Flagpole::update()
16 | {
17 | return false;
18 | }
19 |
20 | std::pair Flagpole::getctpos()
21 | {
22 | return std::make_pair(sx, sy);
23 | }
24 |
25 | Costume Flagpole::getcostume()
26 | {
27 | if (!isshow) return Costume{ -1, -1, -1 };
28 | return Costume{6, 0, 0};
29 | }
30 |
31 | bool Flagpole::report_collision(int direction, Collider* target, int target_collider_layer)
32 | {
33 | return false;
34 | }
35 |
36 | Flag::Flag()
37 | {
38 | collider_layer = -1;
39 | id = ++COLLIDER_ID;
40 | sx = -0.5;
41 | freeze = true;
42 | name = "flag";
43 | show_layer = 1;
44 | }
45 |
46 | bool Flag::update()
47 | {
48 | if (!level.finish_time) return false;
49 | sy = min(8.0 * (level.now_time - level.finish_time) / 1500.0, 8.0);
50 | return true;
51 | }
52 |
53 | std::pair Flag::getctpos()
54 | {
55 | return std::make_pair(sx, sy);
56 | }
57 |
58 | Costume Flag::getcostume()
59 | {
60 | if (!isshow) return Costume{ -1, -1, -1 };
61 | return Costume{ 7, 0, 0 };
62 | }
63 |
64 | bool Flag::report_collision(int direction, Collider* target, int target_collider_layer)
65 | {
66 | return false;
67 | }
68 |
69 | Small_flag::Small_flag()
70 | {
71 | collider_layer = -1;
72 | id = ++COLLIDER_ID;
73 | //sx = -0.5;
74 | freeze = true;
75 | show_layer = 0;
76 | name = "small_flag";
77 | }
78 |
79 | bool Small_flag::update()
80 | {
81 | if (!level.finish_time || level.now_time - level.finish_time < 4000) return false;
82 | sy = -min(2 * (level.now_time - level.finish_time - 4000) / 1500.0, 2);
83 | return true;
84 | }
85 |
86 | std::pair Small_flag::getctpos()
87 | {
88 | return std::make_pair(sx, sy);
89 | }
90 |
91 | Costume Small_flag::getcostume()
92 | {
93 | if (!isshow) return Costume{ -1, -1, -1 };
94 | return Costume{ 10, 0, 0 };
95 | }
96 |
97 | bool Small_flag::report_collision(int direction, Collider* target, int target_collider_layer)
98 | {
99 | return false;
100 | }
--------------------------------------------------------------------------------
/flagpole.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/flagpole.h
--------------------------------------------------------------------------------
/flower.cpp:
--------------------------------------------------------------------------------
1 | #include "flower.h"
2 | #include "musicplayer.h"
3 | #include "level.h"
4 | Flower::Flower(char* s)
5 | {
6 | ct = Costume{ 14, 0, 0 };
7 | sscanf(s, "%d%d", &ct.b, &ct.c);
8 | fx = 0;
9 | collider_layer = 4;
10 | freeze = false;
11 | id = ++COLLIDER_ID;
12 | width = 1, height = 1;
13 | name = "flower";
14 | show_layer = 3;
15 | }
16 |
17 | bool Flower::update()
18 | {
19 | return false;
20 | }
21 |
22 | std::pair Flower::getctpos()
23 | {
24 | return std::make_pair(sx, sy);
25 | }
26 |
27 | Costume Flower::getcostume()
28 | {
29 | if (!isshow) return Costume{ -1, -1, -1 };
30 | return ct;
31 | }
32 |
33 | bool Flower::report_collision(int direction, Collider* target, int target_collider_layer)
34 | {
35 | if (!isrun) return false;
36 | switch (target_collider_layer) {
37 | case 0:
38 | level.remove(this);
39 | musicplayer.play("sound-powerup");
40 | break;
41 | }
42 | return true;
43 | }
--------------------------------------------------------------------------------
/flower.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/flower.h
--------------------------------------------------------------------------------
/freeze_block.cpp:
--------------------------------------------------------------------------------
1 | #include "freeze_block.h"
2 |
3 | Freeze_block::Freeze_block(Costume ct, int show_layer, double width, double hetght)
4 | {
5 | this->ct = ct;
6 | this->show_layer = show_layer;
7 | collider_layer = -1;
8 | id = ++COLLIDER_ID;
9 | freeze = true;
10 | this->width = width, this->height = height;
11 | name = "freeze_block";
12 | show_layer = 1;
13 | }
14 |
15 | bool Freeze_block::update()
16 | {
17 | return false;
18 | }
19 |
20 | std::pair Freeze_block::getctpos()
21 | {
22 | return std::make_pair(sx, sy);
23 | }
24 |
25 | Costume Freeze_block::getcostume()
26 | {
27 | if (!isshow) return Costume{ -1, -1, -1 };
28 | return ct;
29 | }
30 |
31 | bool Freeze_block::report_collision(int direction, Collider* target, int target_collider_layer)
32 | {
33 | return false;
34 | }
35 |
--------------------------------------------------------------------------------
/freeze_block.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/freeze_block.h
--------------------------------------------------------------------------------
/global.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/global.cpp
--------------------------------------------------------------------------------
/global.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/global.h
--------------------------------------------------------------------------------
/graphics.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/graphics.h
--------------------------------------------------------------------------------
/graphics.txt:
--------------------------------------------------------------------------------
1 | resources/graphics/mario_bros.png 80 0 16 32 1 0 19 16 Big_mario
2 | resources/graphics/mario_bros.png 80 32 16 16 1 0 14 16 Small_mario
3 | resources/graphics/mario_bros.png 80 48 16 32 1 0 19 16 Fire_mario
4 | resources/graphics/tile_set.png 0 0 16 16 8 16 4 16 Brick
5 | resources/graphics/smb_enemies_sheet.png 0 4 16 16 3 30 3 30 Chestnut
6 | resources/graphics/tile_set.png 260 136 8 24 6 32 1 0 Pole
7 | resources/graphics/item_objects.png 128 32 16 16 1 0 1 0 Flag
8 | resources/graphics/tile_set.png 176 0 16 16 8 16 12 16 Sp_brick
9 | resources/graphics/tile_set.png 384 0 16 16 8 16 12 16 Question_Block
10 | resources/graphics/item_objects.png 128 0 16 16 1 0 1 0 Small_flag
11 | resources/graphics/item_objects.png 0 0 16 16 2 16 3 16 Mushroom
12 | resources/graphics/tile_set.png 384 16 16 16 4 32 3 16 Coin
13 | resources/graphics/smb_enemies_sheet.png 90 0 16 24 3 30 10 30 Tortoise
14 | resources/graphics/item_objects.png 0 32 16 16 1 16 3 16 Flower
15 | resources/graphics/item_objects.png 0 48 16 16 1 16 3 16 Star
16 | resources/graphics/smb_enemies_sheet.png 360 184 16 16 1 30 3 30 Mario_fire
17 | resources/graphics/mario_bros.png 80 144 16 32 1 0 19 16 Big_invincible_mario
18 | resources/graphics/mario_bros.png 80 176 16 16 1 0 14 16 Small_invincible_mario
19 |
--------------------------------------------------------------------------------
/graphics64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/graphics64.lib
--------------------------------------------------------------------------------
/headers.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/headers.cpp
--------------------------------------------------------------------------------
/headers.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/headers.h
--------------------------------------------------------------------------------
/keymsg.cpp:
--------------------------------------------------------------------------------
1 | #include "keymsg.h"
2 | #include "level.h"
3 | void Keymsg::update()
4 | {
5 | msg.clear();
6 | while (kbmsg()) {
7 | key_msg k = getkey();
8 | msg.push_back(k);
9 | bool flag = (k.msg == key_msg_down);
10 | if (flag || k.msg == key_msg_up) {
11 | if (!is_down[k.key])
12 | down_time[k.key] = level.now_time;
13 | is_down[k.key] = flag;
14 | }
15 |
16 | }
17 | }
18 |
19 | bool Keymsg::getmsg(key_msg& m, int key)
20 | {
21 | for (auto i = msg.rbegin(); i != msg.rend(); i++) {
22 | if (i->key == key) {
23 | m = *i;
24 | return true;
25 | }
26 | }
27 | return false;
28 | }
29 | Keymsg keymsg;
30 |
--------------------------------------------------------------------------------
/keymsg.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/keymsg.h
--------------------------------------------------------------------------------
/level.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/level.cpp
--------------------------------------------------------------------------------
/level.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/level.h
--------------------------------------------------------------------------------
/level_data/1-1.mio:
--------------------------------------------------------------------------------
1 | map_range 35
2 | limit_time 120
3 | end
4 | 11 11 4 0 0
5 | 12 11 4 0 0
6 | 13 11 4 0 0
7 | 14 11 4 0 0
8 | 15 11 4 0 0
9 | 16 11 4 0 0
10 | 17 11 4 0 0
11 | 18 11 4 0 0
12 | 19 11 4 0 0
13 | 20 11 4 0 0
14 | 10 12 4 0 0
15 | 11 12 4 0 0
16 | 12 12 4 0 0
17 | 13 12 4 0 0
18 | 14 12 4 0 0
19 | 15 12 4 0 0
20 | 16 12 4 0 0
21 | 17 12 4 0 0
22 | 18 12 4 0 0
23 | 19 9 4 0 0
24 | 19 8 4 1 1
25 | 19 7 4 1 1
26 | 20 9 4 1 1
27 | 20 8 4 1 1
28 | 20 7 4 1 1
29 | 0 13 4 0 0
30 | 1 13 4 0 0
31 | 2 13 4 0 0
32 | 3 13 4 0 0
33 | 4 13 4 0 0
34 | 5 13 4 0 0
35 | 6 13 4 0 0
36 | 6 12 4 1 0
37 | 6 11 4 1 0
38 | 6 10 4 1 0
39 | 6 9 4 1 0
40 | 16 13 4 0 0
41 | 17 13 4 0 0
42 | 18 13 4 0 0
43 | 19 13 4 0 0
44 | 20 13 4 0 0
45 | 0 14 4 0 0
46 | 1 14 4 0 0
47 | 2 14 4 0 0
48 | 3 14 4 0 0
49 | 4 14 4 0 0
50 | 5 14 4 0 0
51 | 6 14 4 0 0
52 | 7 14 4 0 0
53 | 8 14 4 0 0
54 | 9 14 4 0 0
55 | 10 14 4 0 0
56 | 11 14 4 0 0
57 | 12 14 4 0 0
58 | 13 14 4 0 0
59 | 14 14 4 0 0
60 | 15 14 4 0 0
61 | 16 14 4 0 0
62 | 17 14 4 0 0
63 | 18 14 4 0 0
64 | 19 14 4 0 0
65 | 20 8 4 1 1
66 | 12 7 4 1 1
67 | 13 7 4 1 1
68 | 14 7 4 1 1
69 | 15 9 4 1 1
70 | 16 9 4 1 1
71 | 17 8 4 1 1
72 | 18 8 4 1 1
73 | 19 9 4 1 1
74 | 20 10 4 1 1
75 | 20 11 4 1 1
76 | 18 10 5 1
77 | 17 10 5 1
78 | 6 6 11 0 0 1
79 | 2 9 9 0 14 0 0
80 | 3 9 9 1 15 0 0 1
81 | 3 11 12
82 | 4 11 12
83 | 5 11 12
84 | 25 10 4 0 0
85 | 15 13 13 -1
86 | -1 -1
87 | -1 -1
--------------------------------------------------------------------------------
/level_data/1-2.mio:
--------------------------------------------------------------------------------
1 | map_range 100
2 | end
3 | 0 13 4 1 0
4 | 1 13 4 1 0
5 | 2 13 4 1 0
6 | 3 13 4 1 0
7 | 4 13 4 1 0
8 | 5 13 4 1 0
9 | 6 13 4 1 0
10 | 7 13 4 1 0
11 | 8 13 4 1 0
12 | 9 13 4 1 0
13 | 10 13 4 1 0
14 | 11 13 4 1 0
15 | 12 13 4 1 0
16 | 13 13 4 1 0
17 | 14 13 4 1 0
18 | 15 13 4 1 0
19 | 16 13 4 1 0
20 | 17 13 4 1 0
21 | 18 13 4 1 0
22 | 19 13 4 1 0
23 | 20 13 4 1 0
24 | 21 13 4 1 0
25 | 5 11 4 1 0
26 | 6 11 4 1 0
27 | 7 11 4 1 0
28 | 8 11 4 1 0
29 | 9 11 4 1 0
30 | 10 11 4 1 0
31 | 11 11 4 1 0
32 | 12 11 4 1 0
33 | 13 11 4 1 0
34 | 14 11 4 1 0
35 | 15 11 4 1 0
36 | 16 11 4 1 0
37 | 17 11 4 1 0
38 | 18 11 4 1 0
39 | 19 11 4 1 0
40 | 20 11 4 1 0
41 | 21 11 4 1 0
42 | 22 11 4 1 0
43 | 23 11 4 1 0
44 | 24 11 4 1 0
45 | 25 11 4 1 0
46 | 26 11 4 1 0
47 | 5 5 15 0 0 -1
48 | 25 10 5 -1
49 | -1 -1
--------------------------------------------------------------------------------
/level_data/1-3.mio:
--------------------------------------------------------------------------------
1 | map_range 50
2 | limit_time 300
3 | end
4 | 0 13 4 0 0
5 | 1 13 4 0 0
6 | 2 13 4 0 0
7 | 3 13 4 0 0
8 | 4 13 4 0 0
9 | 5 13 4 0 0
10 | 6 13 4 0 0
11 | 16 13 4 0 0
12 | 17 13 4 0 0
13 | 18 13 4 0 0
14 | 19 13 4 0 0
15 | 20 13 4 0 0
16 | 0 14 4 0 0
17 | 1 14 4 0 0
18 | 2 14 4 0 0
19 | 3 14 4 0 0
20 | 4 14 4 0 0
21 | 5 14 4 0 0
22 | 6 14 4 0 0
23 | 7 14 4 0 0
24 | 8 14 4 0 0
25 | 9 14 4 0 0
26 | 10 14 4 0 0
27 | 11 14 4 0 0
28 | 12 14 4 0 0
29 | 13 14 4 0 0
30 | 14 14 4 0 0
31 | 15 14 4 0 0
32 | 16 14 4 0 0
33 | 17 14 4 0 0
34 | 18 14 4 0 0
35 | 19 14 4 0 0
36 | 7 13 4 0 0
37 | 8 13 4 0 0
38 | 9 13 4 0 0
39 | 10 13 4 0 0
40 | 11 13 4 0 0
41 | 12 13 4 0 0
42 | 13 13 4 0 0
43 | 14 13 4 0 0
44 | 15 13 4 0 0
45 | 20 14 4 0 0
46 | 21 13 4 0 0
47 | 22 13 4 0 0
48 | 23 13 4 0 0
49 | 24 13 4 0 0
50 | 25 13 4 0 0
51 | 26 13 4 0 0
52 | 21 14 4 0 0
53 | 22 14 4 0 0
54 | 23 14 4 0 0
55 | 24 14 4 0 0
56 | 25 14 4 0 0
57 | 26 14 4 0 0
58 | 27 14 4 0 0
59 | 28 14 4 0 0
60 | 29 14 4 0 0
61 | 30 14 4 0 0
62 | 27 13 4 0 0
63 | 28 13 4 0 0
64 | 29 13 4 0 0
65 | 30 13 4 0 0
66 | 8 12 13 1
67 | 9 12 13 1
68 | 10 12 13 1
69 | 11 12 5 1
70 | 12 12 5 1
71 | 13 12 5 1
72 | 2 9 9 0 15 0 0 1
73 | 10 11 4 1 1
74 | 9 11 4 1 1
75 | 8 11 4 1 1
76 | 7 11 4 1 1
77 | 6 11 4 1 1
78 | 5 11 4 1 1
79 | 5 10 4 1 1
80 | 5 9 4 1 1
81 | 5 8 4 1 1
82 | 5 7 4 1 1
83 | 5 6 4 1 1
84 | 5 5 4 1 1
85 | 19 12 4 1 1
86 | 0 12 11 0 0 1
87 | -1 -1
88 | -1 -1
--------------------------------------------------------------------------------
/level_data/1-4.mio:
--------------------------------------------------------------------------------
1 | map_range 40
2 | limit_time 300
3 | end
4 | 0 13 4 0 0
5 | 1 13 4 0 0
6 | 2 13 4 0 0
7 | 3 13 4 0 0
8 | 4 13 4 0 0
9 | 5 13 4 0 0
10 | 6 13 4 0 0
11 | 16 13 4 0 0
12 | 17 13 4 0 0
13 | 18 13 4 0 0
14 | 19 13 4 0 0
15 | 20 13 4 0 0
16 | 0 14 4 0 0
17 | 1 14 4 0 0
18 | 2 14 4 0 0
19 | 3 14 4 0 0
20 | 4 14 4 0 0
21 | 5 14 4 0 0
22 | 6 14 4 0 0
23 | 7 14 4 0 0
24 | 8 14 4 0 0
25 | 9 14 4 0 0
26 | 10 14 4 0 0
27 | 11 14 4 0 0
28 | 12 14 4 0 0
29 | 13 14 4 0 0
30 | 14 14 4 0 0
31 | 15 14 4 0 0
32 | 16 14 4 0 0
33 | 17 14 4 0 0
34 | 18 14 4 0 0
35 | 19 14 4 0 0
36 | 7 13 4 0 0
37 | 8 13 4 0 0
38 | 9 13 4 0 0
39 | 10 13 4 0 0
40 | 11 13 4 0 0
41 | 12 13 4 0 0
42 | 13 13 4 0 0
43 | 14 13 4 0 0
44 | 15 13 4 0 0
45 | 20 14 4 0 0
46 | 21 13 4 0 0
47 | 22 13 4 0 0
48 | 23 13 4 0 0
49 | 24 13 4 0 0
50 | 25 13 4 0 0
51 | 26 13 4 0 0
52 | 21 14 4 0 0
53 | 22 14 4 0 0
54 | 23 14 4 0 0
55 | 24 14 4 0 0
56 | 25 14 4 0 0
57 | 26 14 4 0 0
58 | 27 14 4 0 0
59 | 28 14 4 0 0
60 | 29 14 4 0 0
61 | 30 14 4 0 0
62 | 27 13 4 0 0
63 | 28 13 4 0 0
64 | 29 13 4 0 0
65 | 30 13 4 0 0
66 | 20 12 4 1 0
67 | 21 12 4 1 0
68 | 22 12 4 1 0
69 | 23 12 4 1 0
70 | 24 12 4 1 0
71 | 25 12 4 1 0
72 | 26 12 4 1 0
73 | 27 12 4 1 0
74 | 21 11 4 1 0
75 | 22 11 4 1 0
76 | 23 11 4 1 0
77 | 24 11 4 1 0
78 | 25 11 4 1 0
79 | 26 11 4 1 0
80 | 27 11 4 1 0
81 | 22 10 4 1 0
82 | 23 10 4 1 0
83 | 24 10 4 1 0
84 | 25 10 4 1 0
85 | 26 10 4 1 0
86 | 27 10 4 1 0
87 | 23 9 4 1 0
88 | 24 9 4 1 0
89 | 25 9 4 1 0
90 | 26 9 4 1 0
91 | 27 9 4 1 0
92 | 24 8 4 1 0
93 | 25 8 4 1 0
94 | 26 8 4 1 0
95 | 27 8 4 1 0
96 | 25 7 4 1 0
97 | 26 7 4 1 0
98 | 27 7 4 1 0
99 | 26 6 4 1 0
100 | 27 6 4 1 0
101 | 27 5 4 1 0
102 | -1 -1
103 | -1 -1
--------------------------------------------------------------------------------
/load_screen.cpp:
--------------------------------------------------------------------------------
1 | #include "load_screen.h"
2 | #include "global.h"
3 | #include "graphics.h"
4 | #include "level.h"
5 | #include "menu.h"
6 | #include "musicplayer.h"
7 | #include
8 |
9 | Load_screen::Load_screen()
10 | {
11 | mario = newimage();
12 | getimage1(mario, "resources\\graphics\\mario_bros.png", 320, 8, 335, 31);
13 | zoomImage(mario, 1.5);
14 | }
15 |
16 | bool Load_screen::render()
17 | {
18 | if (!isshow) return false;
19 | bar(0, 0, 800, 600);
20 | if (name == "begin") {
21 | xyprintf(280, 200, "WORLD");
22 | xyprintf(400, 200, LEVEL_NAME.c_str());
23 | putimage_withalpha(NULL, mario, 330, 300);
24 | xyprintf(390, 300, "x");
25 | char s[5];
26 | sprintf_s(s, "%d", LIVES);
27 | xyprintf(430, 300, s);
28 | }
29 | else if (name == "game_over") {
30 | xyprintf(300, 300, "GAME OVER");
31 | }
32 | else if (name == "course_clear") {
33 | xyprintf(280, 300, "COURSE CLEAR");
34 | }
35 | return true;
36 | }
37 |
38 | bool Load_screen::update()
39 | {
40 | if (!isrun) return false;
41 | int tim = name == "begin" ? 2000 : 5000;
42 | if (clock() - start_time > tim) {
43 | stop();
44 | return false;
45 | }
46 | return render();
47 | }
48 |
49 | void Load_screen::start(std::string name)
50 | {
51 | level.stop();
52 | isshow = true;
53 | isrun = true;
54 | start_time = clock();
55 | this->name = name;
56 | if (name == "begin") {
57 | musicplayer.play("sound-begin");
58 | }
59 | else if (name == "game_over") {
60 | level.freeze = true;
61 | musicplayer.play("music-game_over");
62 | }
63 | else if (name == "course_clear") {
64 | option_cursor.levels_top_score[LEVEL_NAME] = max(SCORE, option_cursor.levels_top_score[LEVEL_NAME]);
65 | musicplayer.play("music-course_clear");
66 | }
67 | }
68 |
69 | void Load_screen::stop()
70 | {
71 | isshow = false;
72 | isrun = false;
73 | if (name == "begin") {
74 | level.freeze = false;
75 | level.start();
76 | }
77 | else if (name == "game_over" || name == "course_clear") {
78 | menu.start();
79 | }
80 |
81 | }
82 | Load_screen load_screen;
83 |
84 |
85 |
--------------------------------------------------------------------------------
/load_screen.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/load_screen.h
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/main.cpp
--------------------------------------------------------------------------------
/mario.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mario.cpp
--------------------------------------------------------------------------------
/mario.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mario.h
--------------------------------------------------------------------------------
/mario.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31903.59
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mario", "mario.vcxproj", "{B1E14968-08D5-4938-B729-4AA34C0BC56B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Debug|x64.ActiveCfg = Debug|x64
17 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Debug|x64.Build.0 = Debug|x64
18 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Debug|x86.ActiveCfg = Debug|Win32
19 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Debug|x86.Build.0 = Debug|Win32
20 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Release|x64.ActiveCfg = Release|x64
21 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Release|x64.Build.0 = Release|x64
22 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Release|x86.ActiveCfg = Release|Win32
23 | {B1E14968-08D5-4938-B729-4AA34C0BC56B}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {2E906DB0-D2B9-441A-8386-138417801A86}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/mario.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {b1e14968-08d5-4938-b729-4aa34c0bc56b}
25 | mario
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v143
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v143
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v143
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v143
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | false
78 |
79 |
80 | true
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Level3
88 | true
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Level3
100 | true
101 | true
102 | true
103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
104 | true
105 |
106 |
107 | Console
108 | true
109 | true
110 | true
111 |
112 |
113 |
114 |
115 | Level3
116 | true
117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 |
120 |
121 | Console
122 | true
123 |
124 |
125 |
126 |
127 | Level3
128 | true
129 | true
130 | true
131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
132 | true
133 |
134 |
135 | Console
136 | true
137 | true
138 | true
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
--------------------------------------------------------------------------------
/mario.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件
50 |
51 |
52 | 头文件
53 |
54 |
55 | 头文件
56 |
57 |
58 | 头文件
59 |
60 |
61 | 头文件
62 |
63 |
64 | 头文件
65 |
66 |
67 | 头文件
68 |
69 |
70 | 头文件
71 |
72 |
73 | 头文件
74 |
75 |
76 | 头文件
77 |
78 |
79 | 头文件
80 |
81 |
82 | 头文件
83 |
84 |
85 | 头文件
86 |
87 |
88 | 头文件
89 |
90 |
91 | 头文件
92 |
93 |
94 | 头文件
95 |
96 |
97 | 头文件
98 |
99 |
100 | 头文件
101 |
102 |
103 | 头文件
104 |
105 |
106 | 头文件
107 |
108 |
109 | 头文件
110 |
111 |
112 |
113 |
114 | 源文件
115 |
116 |
117 | 源文件
118 |
119 |
120 | 源文件
121 |
122 |
123 | 源文件
124 |
125 |
126 | 源文件
127 |
128 |
129 | 源文件
130 |
131 |
132 | 源文件
133 |
134 |
135 | 源文件
136 |
137 |
138 | 源文件
139 |
140 |
141 | 源文件
142 |
143 |
144 | 源文件
145 |
146 |
147 | 源文件
148 |
149 |
150 | 源文件
151 |
152 |
153 | 源文件
154 |
155 |
156 | 源文件
157 |
158 |
159 | 源文件
160 |
161 |
162 | 源文件
163 |
164 |
165 | 源文件
166 |
167 |
168 | 源文件
169 |
170 |
171 | 源文件
172 |
173 |
174 | 源文件
175 |
176 |
177 | 源文件
178 |
179 |
180 | 源文件
181 |
182 |
183 | 源文件
184 |
185 |
186 |
187 |
188 | 资源文件
189 |
190 |
191 |
192 |
193 | 资源文件
194 |
195 |
196 |
--------------------------------------------------------------------------------
/mario_fire.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mario_fire.cpp
--------------------------------------------------------------------------------
/mario_fire.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mario_fire.h
--------------------------------------------------------------------------------
/menu.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/menu.cpp
--------------------------------------------------------------------------------
/menu.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/menu.h
--------------------------------------------------------------------------------
/mushroom.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mushroom.cpp
--------------------------------------------------------------------------------
/mushroom.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/mushroom.h
--------------------------------------------------------------------------------
/musicplayer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/musicplayer.cpp
--------------------------------------------------------------------------------
/musicplayer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/musicplayer.h
--------------------------------------------------------------------------------
/question_block.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/question_block.cpp
--------------------------------------------------------------------------------
/question_block.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/question_block.h
--------------------------------------------------------------------------------
/readme.assets/image-20211117222718152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20211117222718152.png
--------------------------------------------------------------------------------
/readme.assets/image-20211205123022243.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20211205123022243.png
--------------------------------------------------------------------------------
/readme.assets/image-20211205123140803.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20211205123140803.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104102845486.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104102845486.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104103039110.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104103039110.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104103151073.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104103151073.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104103348220.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104103348220.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104103420908.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104103420908.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104103512409.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104103512409.png
--------------------------------------------------------------------------------
/readme.assets/image-20220104104303136.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/readme.assets/image-20220104104303136.png
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Super mario Bros
4 |
5 | made by tuxiaobei
6 |
7 | 四川大学程序设计基础(C语言)与安全:游戏项目(2021级大一上)
8 |
9 | 
10 |
11 | ## 项目基础简介
12 |
13 | 开发环境:Microsoft Visual Studio Community 2022 (64 位) - Current 版本 17.0.0
14 |
15 | 开发语言标准:C++14
16 |
17 | 使用图形库:[Easy Graphics Engine(EGE)](https://xege.org/)
18 |
19 | 请先安装字体文件 [resources/fonts/Fixedsys500c.ttf](https://gitee.com/tuxiaobei/mario/raw/master/resources/fonts/Fixedsys500c.ttf)
20 |
21 | ## 操作方式
22 |
23 | ### 菜单页面
24 |
25 | 上/下方向键:切换关卡
26 |
27 | Enter 键:进入关卡
28 |
29 | D 键:开启/关闭调试模式
30 |
31 | ### 游戏页面
32 |
33 | 左/右方向键:向左/右移动
34 |
35 | 下方向键:在大状态情况下蹲
36 |
37 | X 键:跳跃(在一定范围内,按下时间越长,横向速度越快,跳跃高度越高)
38 |
39 | 长按 Z 键:加速冲刺
40 |
41 | 短按 Z 键:在火焰马里奥状态下射出火球
42 |
43 | D 键:开启/关闭调试模式
44 |
45 | ## 关卡编辑
46 |
47 | 位于 `level_data` 目录下,文件后缀名为 `.mio`,文件名即为关卡名。
48 |
49 | 基础格式:
50 |
51 | ```
52 | map_range 35 //设置地图大小
53 | limit_time 120 //设置时间上限
54 | end
55 | 表世界关卡元素(一行一个)
56 | -1 -1
57 | 里世界关卡元素(一行一个,暂未实现)
58 | -1 -1
59 | ```
60 |
61 | 每一行首先是两个数,表示元素位置坐标 $x$ ,$y$,一个空格后接素材命令
62 |
63 | ### 素材命令
64 |
65 | #### 砖块
66 |
67 |
68 |
69 | 
70 |
71 | ```
72 | 4 <初始造型行数> <初始造型列数>
73 | ```
74 |
75 | #### 板栗
76 |
77 | ```
78 | 5 <初始方向向左-1/向右1>
79 | ```
80 |
81 | #### 问号砖
82 |
83 | ```
84 | 9 <是否隐藏0/1> <出现的角色命令>
85 | ```
86 |
87 | #### 蘑菇
88 |
89 | 
90 |
91 | ```
92 | 11 <初始造型行数> <初始造型列数> <初始方向向左-1/向右1>
93 | ```
94 |
95 | #### 金币
96 |
97 | ```
98 | 12
99 | ```
100 |
101 | #### 乌龟
102 |
103 | ```
104 | 13 <初始造型行数> <初始造型列数> <初始方向向左-1/向右1>
105 | ```
106 |
107 | #### 火焰花
108 |
109 | 
110 |
111 | ```
112 | 14 <初始造型行数> <初始造型列数>
113 | ```
114 |
115 | #### 无敌星
116 |
117 | 
118 |
119 | ```
120 | 15 <初始造型行数> <初始造型列数> <初始方向向左-1/向右1>
121 | ```
122 |
123 | ### 调试模式
124 |
125 | 按 D 键,开启/关闭调试模式
126 |
127 | 
128 |
129 | 方框表示碰撞箱的大小和位置,不同颜色表示不同的碰撞图层
130 |
131 | 圆点表示角色贴图绘制位置的左上角,蓝色表示静态物体,绿色表示动态物体在空中,红色表示动态物体在地面。
132 |
133 | 从碰撞箱中心发出的两条线的长度代表角色受外力的情况(不含摩檫力与引力),颜色表示速度大小(越红速度越快)。
134 |
135 | ## 项目结构
136 |
137 | 本项目采用面向对象的设计思路,以下列举的是类的实现,类的声明均在同名的 `.h` 文件中。
138 |
139 | ### 全局相关
140 |
141 | `main.cpp` 程序初始化和渲染循环控制
142 |
143 | `global.cpp` 全局变量和函数
144 |
145 | `keymsg.cpp` 键盘信息的接收和处理
146 |
147 | `musicplayer.cpp` 音乐文件的读取和控制
148 |
149 | `camera.cpp` 图片素材的读取和渲染控制
150 |
151 | `headers.cpp` 顶端分数、金币、关卡名和时间显示
152 |
153 | ### 页面相关
154 |
155 | `menu.cpp` 菜单页面和选关控制
156 |
157 | `load_screen.cpp` 加载页面
158 |
159 | ### 关卡相关
160 |
161 | `level.cpp` 关卡读取和总体控制
162 |
163 | `collider.cpp` 碰撞箱与物理引擎(以下所有类均继承于此)
164 |
165 | #### 关卡内部角色/动画
166 |
167 | `mario.cpp` 马里奥
168 |
169 | `mario_fire.cpp` 马里奥火球
170 |
171 | `freeze_block.cpp` 静态砖块
172 |
173 | `flagpole.cpp` 终点旗杆与旗帜
174 |
175 | `death_animation.cpp` 角色被击杀动画‘
176 |
177 | `add_score.cpp` 分数增加动画
178 |
179 | #### 关卡可编辑角色
180 |
181 | `brick.cpp` 标准砖块
182 |
183 | `chestnut.cpp` 板栗
184 |
185 | `coin.cpp` 金币
186 |
187 | `flower.cpp` 火焰花
188 |
189 | `mushroom.cpp` 蘑菇
190 |
191 | `question_block.cpp` 问号砖块/隐藏砖块
192 |
193 | `star.cpp` 无敌星
194 |
195 | `tortoise.cpp` 慢慢龟
196 |
197 | ### 其他数据文件
198 |
199 | `graphics.txt` 图片素材位置数据
200 |
201 | 一行一个类型素材的位置数据:
202 |
203 | ```
204 | <素材路径> <初始左上角x坐标> <初始左上角y坐标> <素材宽度> <素材高度> <纵向(y方向)重复次数> <纵向(y方向)每次读取偏移量> <横向(x方向)重复次数> <横向(x方向)每次读取偏移量> <素材名称>
205 | ```
206 |
207 | 可通过 `Costume` 结构体(位于 `global.h`)访问素材造型,由三个 `int` 变量(`a`,`b`,`c`)组成,依次表示造型类型行数,行数(从 $0$ 计数),列数(从 $0$ 计数)
208 |
209 | `level_data` 关卡地图数据目录
210 |
211 | `resources` 图片和音频素材目录
212 |
213 | ## 参考资料
214 |
215 | 1. 素材来源:
216 | 2. EGE 图形库:
217 | 3. EGE 图形库文档:
218 |
219 | ## 注意事项
220 |
221 | 本项目可能在 AMD 平台的机器上出现兼容性问题,如果出现游玩问题请提交 issue
--------------------------------------------------------------------------------
/resources/fonts/Fixedsys500c.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/fonts/Fixedsys500c.ttf
--------------------------------------------------------------------------------
/resources/fonts/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'justinarmstrong'
2 |
--------------------------------------------------------------------------------
/resources/graphics/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'justinarmstrong'
2 |
--------------------------------------------------------------------------------
/resources/graphics/enemies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/enemies.png
--------------------------------------------------------------------------------
/resources/graphics/id.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/id.pptx
--------------------------------------------------------------------------------
/resources/graphics/item_objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/item_objects.png
--------------------------------------------------------------------------------
/resources/graphics/level_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/level_1.png
--------------------------------------------------------------------------------
/resources/graphics/mario_bros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/mario_bros.png
--------------------------------------------------------------------------------
/resources/graphics/smb_enemies_sheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/smb_enemies_sheet.png
--------------------------------------------------------------------------------
/resources/graphics/text_images.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/text_images.png
--------------------------------------------------------------------------------
/resources/graphics/tile_set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/tile_set.png
--------------------------------------------------------------------------------
/resources/graphics/title_screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/graphics/title_screen.png
--------------------------------------------------------------------------------
/resources/music/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'justinarmstrong'
2 |
--------------------------------------------------------------------------------
/resources/music/course_clear.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/course_clear.wav
--------------------------------------------------------------------------------
/resources/music/death.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/death.wav
--------------------------------------------------------------------------------
/resources/music/flagpole.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/flagpole.wav
--------------------------------------------------------------------------------
/resources/music/game_over.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/game_over.mp3
--------------------------------------------------------------------------------
/resources/music/invincible.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/invincible.mp3
--------------------------------------------------------------------------------
/resources/music/main_theme.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/main_theme.mp3
--------------------------------------------------------------------------------
/resources/music/main_theme_sped_up.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/main_theme_sped_up.mp3
--------------------------------------------------------------------------------
/resources/music/out_of_time.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/out_of_time.wav
--------------------------------------------------------------------------------
/resources/music/stage_clear.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/stage_clear.wav
--------------------------------------------------------------------------------
/resources/music/start.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/start.mp3
--------------------------------------------------------------------------------
/resources/music/world_clear.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/music/world_clear.wav
--------------------------------------------------------------------------------
/resources/sound/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'justinarmstrong'
2 |
--------------------------------------------------------------------------------
/resources/sound/begin.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/begin.wav
--------------------------------------------------------------------------------
/resources/sound/big_jump.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/big_jump.mp3
--------------------------------------------------------------------------------
/resources/sound/brick_smash.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/brick_smash.mp3
--------------------------------------------------------------------------------
/resources/sound/bump.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/bump.mp3
--------------------------------------------------------------------------------
/resources/sound/coin.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/coin.mp3
--------------------------------------------------------------------------------
/resources/sound/count_down.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/count_down.mp3
--------------------------------------------------------------------------------
/resources/sound/fireball.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/fireball.mp3
--------------------------------------------------------------------------------
/resources/sound/kick.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/kick.mp3
--------------------------------------------------------------------------------
/resources/sound/main_theme_sped_up.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/main_theme_sped_up.mp3
--------------------------------------------------------------------------------
/resources/sound/one_up.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/one_up.mp3
--------------------------------------------------------------------------------
/resources/sound/pipe.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/pipe.mp3
--------------------------------------------------------------------------------
/resources/sound/powerup.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/powerup.mp3
--------------------------------------------------------------------------------
/resources/sound/powerup_appears.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/powerup_appears.mp3
--------------------------------------------------------------------------------
/resources/sound/small_jump.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/small_jump.mp3
--------------------------------------------------------------------------------
/resources/sound/stomp.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/resources/sound/stomp.mp3
--------------------------------------------------------------------------------
/star.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/star.cpp
--------------------------------------------------------------------------------
/star.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/star.h
--------------------------------------------------------------------------------
/tortoise.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/tortoise.cpp
--------------------------------------------------------------------------------
/tortoise.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuxiaobei-scu/Mario/20eff8077f05690ebca00af42a906b82b37dde22/tortoise.h
--------------------------------------------------------------------------------