diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96374c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/11. februarie 2015 RA postdoc - Copy - Copy.doc b/11. februarie 2015 RA postdoc - Copy - Copy.doc deleted file mode 100644 index ab90049..0000000 Binary files a/11. februarie 2015 RA postdoc - Copy - Copy.doc and /dev/null differ diff --git a/README.md b/README.md deleted file mode 100644 index a577bf3..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ComputerProgrammingLab -Programs developed during the Computer Programming Laboratory at the Faculty of Automation, Computers and Electronics within the University Of Craiova diff --git a/Sp.Inv.cbp b/Sp.Inv.cbp new file mode 100644 index 0000000..c43dd75 --- /dev/null +++ b/Sp.Inv.cbp @@ -0,0 +1,49 @@ + + + + + + diff --git a/Sp.Inv.depend b/Sp.Inv.depend new file mode 100644 index 0000000..49aa4a4 --- /dev/null +++ b/Sp.Inv.depend @@ -0,0 +1,100 @@ +# depslib dependency file v1.0 +1417204052 source:c:\users\razwan\desktop\sp.inv\main.cpp + + + + + + + + + +1418235565 source:c:\users\razwan\desktop\space invaders 2.0\main.cpp + + + + + + + + "resource.h" + +1417542532 source:c:\users\razwan\desktop\space invaders 2.0\resources.rc + "resource.h" + +1417542561 c:\users\razwan\desktop\space invaders 2.0\resource.h + +1417542532 source:c:\users\razwan\desktop\spinv\space invaders 2.0\resources.rc + "resource.h" + +1417542561 c:\users\razwan\desktop\spinv\space invaders 2.0\resource.h + +1420465409 source:c:\users\razwan\desktop\spinv\space invaders 2.0\main.cpp + + + + + + + + "resource.h" + +1421679226 source:c:\users\bogdanel\desktop\spinv\space invaders 2.0\main.cpp + + + + + + + + "resource.h" + +1417542561 c:\users\bogdanel\desktop\spinv\space invaders 2.0\resource.h + +1417542532 source:c:\users\bogdanel\desktop\spinv\space invaders 2.0\resources.rc + "resource.h" + +1417542532 source:c:\users\bogdanel\desktop\space invaders eng\resources.rc + "resource.h" + +1417542561 c:\users\bogdanel\desktop\space invaders eng\resource.h + +1424348207 source:c:\users\bogdanel\desktop\space invaders eng\main.cpp + + + + + + + + "resource.h" + +1417542532 source:c:\users\bogdanel\desktop\space invaders\resources.rc + "resource.h" + +1417542561 c:\users\bogdanel\desktop\space invaders\resource.h + +1424801231 source:c:\users\bogdanel\desktop\space invaders\main.cpp + + + + + + + + "resource.h" + +1417542532 source:c:\users\bogdanel\desktop\dumitru bogdan mihai\resources.rc + "resource.h" + +1417542561 c:\users\bogdanel\desktop\dumitru bogdan mihai\resource.h + +1425488675 source:c:\users\bogdanel\desktop\dumitru bogdan mihai\main.cpp + + + + + + + "resource.h" + diff --git a/Sp.Inv.layout b/Sp.Inv.layout new file mode 100644 index 0000000..8074086 --- /dev/null +++ b/Sp.Inv.layout @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/blink.wav b/audio/blink.wav new file mode 100644 index 0000000..56ed57f Binary files /dev/null and b/audio/blink.wav differ diff --git a/audio/bump.wav b/audio/bump.wav new file mode 100644 index 0000000..246bcee Binary files /dev/null and b/audio/bump.wav differ diff --git a/audio/coin.wav b/audio/coin.wav new file mode 100644 index 0000000..fef4191 Binary files /dev/null and b/audio/coin.wav differ diff --git a/audio/fireworks.wav b/audio/fireworks.wav new file mode 100644 index 0000000..04cd53c Binary files /dev/null and b/audio/fireworks.wav differ diff --git a/audio/gameover.wav b/audio/gameover.wav new file mode 100644 index 0000000..daf9bac Binary files /dev/null and b/audio/gameover.wav differ diff --git a/audio/kick.wav b/audio/kick.wav new file mode 100644 index 0000000..14cc827 Binary files /dev/null and b/audio/kick.wav differ diff --git a/audio/pause.wav b/audio/pause.wav new file mode 100644 index 0000000..0074f74 Binary files /dev/null and b/audio/pause.wav differ diff --git a/audio/pipe.wav b/audio/pipe.wav new file mode 100644 index 0000000..bbeec36 Binary files /dev/null and b/audio/pipe.wav differ diff --git a/audio/powerup.wav b/audio/powerup.wav new file mode 100644 index 0000000..d085783 Binary files /dev/null and b/audio/powerup.wav differ diff --git a/audio/stage_clear.wav b/audio/stage_clear.wav new file mode 100644 index 0000000..6c396de Binary files /dev/null and b/audio/stage_clear.wav differ diff --git a/audio/world_clear.wav b/audio/world_clear.wav new file mode 100644 index 0000000..aad8d86 Binary files /dev/null and b/audio/world_clear.wav differ diff --git a/bin/Debug/Sp.exe b/bin/Debug/Sp.exe new file mode 100644 index 0000000..f2eff71 Binary files /dev/null and b/bin/Debug/Sp.exe differ diff --git a/files/HighScore.txt b/files/HighScore.txt new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/files/HighScore.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/files/Higscores.txt b/files/Higscores.txt new file mode 100644 index 0000000..d3d238b Binary files /dev/null and b/files/Higscores.txt differ diff --git a/files/index_level0.txt b/files/index_level0.txt new file mode 100644 index 0000000..439bd61 --- /dev/null +++ b/files/index_level0.txt @@ -0,0 +1 @@ +3 22 20 15 1 \ No newline at end of file diff --git a/files/level.prezent.txt b/files/level.prezent.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/files/level.prezent.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/files/level0 - Copy.txt b/files/level0 - Copy.txt new file mode 100644 index 0000000..53ca28a --- /dev/null +++ b/files/level0 - Copy.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 1 32 32 32 32 32 32 32 32 32 32 32 32 32 15 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level0.txt b/files/level0.txt new file mode 100644 index 0000000..53ca28a --- /dev/null +++ b/files/level0.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 1 32 32 32 32 32 32 32 32 32 32 32 32 32 15 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level1.txt b/files/level1.txt new file mode 100644 index 0000000..f8986a0 --- /dev/null +++ b/files/level1.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level10.txt b/files/level10.txt new file mode 100644 index 0000000..1f4c00e --- /dev/null +++ b/files/level10.txt @@ -0,0 +1,16 @@ +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 +4 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 4 +4 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 4 4 4 4 4 32 32 32 32 4 32 32 32 32 4 4 4 4 4 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 4 4 4 4 32 32 32 32 4 32 4 32 32 32 32 4 4 4 4 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 4 4 4 32 32 32 32 4 32 32 32 4 32 32 32 32 4 4 4 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 4 4 32 32 32 32 4 32 32 32 32 32 4 32 32 32 32 4 4 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 4 32 32 32 32 4 32 32 32 32 32 32 32 4 32 32 32 32 4 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 4 4 32 32 32 32 4 32 32 32 32 4 4 32 32 32 4 32 32 32 32 4 4 32 32 4 32 32 32 4 +4 32 32 4 32 32 32 32 32 32 32 4 32 32 32 32 4 32 32 4 32 32 32 4 32 32 32 32 32 32 32 4 32 32 32 4 +4 32 32 4 32 32 32 32 32 32 4 32 32 32 32 4 32 32 32 32 4 32 32 32 4 32 32 32 32 32 32 4 32 32 32 4 +4 32 32 4 32 32 32 32 32 4 32 32 32 32 4 32 32 32 32 32 32 4 32 32 32 4 4 4 4 4 4 4 32 32 32 4 +4 32 32 4 4 4 4 4 4 32 32 32 32 4 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 4 +4 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 4 +4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 6 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 diff --git a/files/level2.txt b/files/level2.txt new file mode 100644 index 0000000..e1da55b --- /dev/null +++ b/files/level2.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 32 32 32 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 4 4 4 4 4 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 4 4 4 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +-37 -37 32 32 32 32 32 32 -37 -37 32 32 32 32 32 32 -37 -37 -37 32 32 32 32 32 32 32 -37 -37 32 32 32 32 32 32 -37 -37 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level3.txt b/files/level3.txt new file mode 100644 index 0000000..131312a --- /dev/null +++ b/files/level3.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 4 4 32 32 4 4 4 32 32 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 4 4 32 32 4 4 4 32 32 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 -37 32 -37 -37 32 32 32 -37 -37 32 -37 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level4.txt b/files/level4.txt new file mode 100644 index 0000000..4a73840 --- /dev/null +++ b/files/level4.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 -37 -37 -37 -37 32 32 32 32 32 32 32 32 -37 -37 -37 -37 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level5.txt b/files/level5.txt new file mode 100644 index 0000000..72c011e --- /dev/null +++ b/files/level5.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level6.txt b/files/level6.txt new file mode 100644 index 0000000..03523fc --- /dev/null +++ b/files/level6.txt @@ -0,0 +1,16 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 4 32 32 32 32 +32 32 32 32 32 32 32 -37 -37 -37 32 32 32 32 32 32 -37 -37 -37 32 32 32 32 32 32 -37 -37 -37 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level7.txt b/files/level7.txt new file mode 100644 index 0000000..d892961 --- /dev/null +++ b/files/level7.txt @@ -0,0 +1,16 @@ +4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level8.txt b/files/level8.txt new file mode 100644 index 0000000..581e238 --- /dev/null +++ b/files/level8.txt @@ -0,0 +1,16 @@ +4 4 4 4 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 +4 4 4 4 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 +4 4 4 4 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 4 4 4 4 +4 4 4 4 32 32 32 32 32 32 32 32 -37 -37 -37 -37 -37 -37 -37 -37 -37 -37 32 32 32 32 32 32 32 32 32 32 4 4 4 4 +4 4 4 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 +4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 +4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/level9.txt b/files/level9.txt new file mode 100644 index 0000000..b89ece7 --- /dev/null +++ b/files/level9.txt @@ -0,0 +1,16 @@ +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 +32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 +32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 4 4 4 4 4 4 4 4 4 4 4 4 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/files/levelCMSN.txt b/files/levelCMSN.txt new file mode 100644 index 0000000..316b35f --- /dev/null +++ b/files/levelCMSN.txt @@ -0,0 +1,11 @@ +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 +32 32 32 32 32 32 32 32 32 32 32 32 6 32 32 32 32 32 32 32 32 32 32 32 32 32 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..c75b999 --- /dev/null +++ b/main.cpp @@ -0,0 +1,2002 @@ +#include +#include +#include +#include +#include +#include +#include "resource.h" + +using namespace std; + +const int xspaceship=17; +const int yspaceship=15; + +struct Coordinates{ + int x, y; +}; + struct Coordinates coord_player_spaceship; + struct Coordinates dim_matrix; + struct Coordinates bonus; + struct Coordinates malus; // malus remove your bonus + +struct Present_Minim_Maxim{ + int present; + int minim; + int maxim; +}; + struct Present_Minim_Maxim level; + struct Present_Minim_Maxim weapon; // player can fire 1, 2 or 3 rockets simultaneously + +enum direction {lleft,rright,up,down}; + enum direction direction_enemy_move_x = rright; + enum direction direction_enemy_move_Y = down; + enum direction rnd_move; + + int i,j; + char m[55][55]; // matricea campului de lupta + int nr_lifes=3, nr_cheats, scor=0; + int var; char ch; + int nr_scores; // nr of saved scores + int scores_int[11]; // keep value of the score + char scores_char[11][55]; + char new_score_char[55]; + char cheats[10][15]; // strings of the cheats + char cheat_entered[15]; + // each menu is saven in separate matrix. + // Each menu have a number ( nr_menu ) and it keeps track of the current menu. + char menu[16][16], menu_settings[16][22], menu_scores[15][18],menu_instructions[15][15], menu_leved_customize[15][15]; + int nr_menu, nr_elements_menu[11], highlighted_menu_element; + bool quit=false, sound=true, autoplay=false, level_runs=false, menu_is_displayed=true ; + bool exists_Bonus = false, exists_Malus = false; + bool level_was_changed = false; + bool exists_player_rocker[36]; + +int poz_enemy_x[100],poz_enemy_y[100],nr_enemies; +int y_limit_rand_move_enemy; + +void Finding_y_limit_rand_move_enemy(); +void Move_spaceship_random(int x, int y, int y_limit_rand_move_enemy); +void Find_poz_enemy_xy_AND_poz_player(); +void Move_Rand_Enemy_Spaceships(); +void Move_Y_Enemy_Spaceships(); +void Move_X_Enemy_Spaceships( double &i_Move_X_Enemy_Spaceships ); +void Move_Enemy_Rockets(); +void Move_Player_Rockets( double &i_Player_Fire ); +void Move_Player_Spaceship(char direction_move_player); +void Fire_Rocket(int i,int j,char rocket); +void Enemy_fire(); +void Player_Fire(); +void Show_Menu( int nr_menu, int highlighted_menu_element); +void Enter ( int &nr_menu , int &highlighted_menu_element ); +void Load_scores(); +void Save_scores(); +void Show_scores(); +void Swap_scores(int a, int b); +void Sort_scores(); +void Add_New_scores(); +void Show_Matrix(); +void Save_Game(); +void int_to_char( int level, char *level_actual_char ); +void Load_Level(int nrlevel); +void Save_Level(int nrlevel); +void Customize_Level(int nrlevel); +void Add_Bonus(); +void Remove_Bonus(); +void Add_Malus(); +void Remove_Malus(); +void PleaseWaitScreen(); +void Initialization_Menu(); +void Initialization_Variables(); +void GotoXY( int y, int x); +void Delete_Character(int x , int y); +void Print(int x , int y, char c); +int GameOver(); +void Add_Score(int bonus); +void Decrease_Life(int malus); +int Max(int c, int d); +void Auto_Play(double *time, double *i_Player_Fire, double *lt_Player_Fire ); + +int main() +{ + srand ( time(NULL) );//for the function rand() to return different values every time + + std::clock_t start; + start = std::clock(); + double time; + time = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; + + // intervals for the various actions/functions of the game + double lt_Player_Fire = time; // lt = last time + double lt_Move_Player_Rockets = time; + double lt_Move_Enemy_Rockets = time; + double lt_Enemy_fire = time; +// double lt_Move_Player_Spaceship = start; + double lt_Move_X_Enemy_Spaceships = time; +// double lt_Move_Y_Enemy_Spaceships = start; + double lt_Move_Rand_Enemy_Spaceships = time; + double lt_Add_Bonus = time; + double lt_Add_Malus = time + 5.0; + double lt_modif_y_limit_rand_move_enemy = time; + + double i_Player_Fire = 0.75; + double i_Move_Player_Rockets = 0.015; + double i_Move_Enemy_Rockets=0.45; + double i_Enemy_fire=6.0; +// double i_Move_Player_Spaceship=0.0; + double i_Move_X_Enemy_Spaceships=0.70; +// double i_Move_Y_Enemy_Spaceships=12.5; + double i_Move_Rand_Enemy_Spaceships=0.2; + double i_Add_Bonus=8.0; + double i_Remove_Bonus=3.5; + double i_Add_Malus=8.5; + double i_Remove_Malus=5.0; + double i_modif_y_limit_rand_move_enemy=5.5; + int i_Main = 35; + + PleaseWaitScreen(); // useless, annoying but funny + + Initialization_Variables(); + Load_Level( level.present ); // level.present==0 and load last game ( level0 and index_level0 ) + Load_scores(); + Initialization_Menu(); + + Show_Menu(nr_menu, highlighted_menu_element); + + while(nr_lifes>0 && quit == false){ + time = ( std::clock() - start ) / (double) CLOCKS_PER_SEC ; + + if ( level_was_changed == true ){ //if the level was changed + i_Move_X_Enemy_Spaceships=0.55; // horizontal movement interval for enemy ships return to normal + if( i_Enemy_fire - level.present >= 1.0 ) { // increase the speed which enemy fire + i_Enemy_fire -= level.present; + } + level_was_changed = false; + } + + if( level_runs==true ){ // DACA jucatorul jocaca jocul pr zis ( levelul ruleaza ) + GameOver(); // check if exist enemy ships + + if(autoplay==true){ + Auto_Play(&time, &i_Player_Fire, <_Player_Fire); + } + else{//autoplay==false + if(( GetAsyncKeyState( 'A' ) & 0x8000 ) || ( GetAsyncKeyState( VK_LEFT ) & 0x8000 ) ){ // if "A" or LEFT key is pressed then move player spaceship to the left + Move_Player_Spaceship('A'); + } + if(( GetAsyncKeyState( 'S' ) & 0x8000 ) || ( GetAsyncKeyState( VK_DOWN ) & 0x8000 ) ){ + Move_Player_Spaceship('S'); + } + if(( GetAsyncKeyState( 'D' ) & 0x8000 ) || ( GetAsyncKeyState( VK_RIGHT ) & 0x8000 ) ){ + Move_Player_Spaceship('D'); + } + if( ( GetAsyncKeyState( 'W' ) & 0x8000 ) || ( GetAsyncKeyState( VK_UP ) & 0x8000 ) ){ + Move_Player_Spaceship('W'); + } + if( GetAsyncKeyState( VK_SPACE ) & 0x8000 ){ // If space key is pressed + if(time - lt_Player_Fire >= i_Player_Fire) { // present time - last time player fire > shooting interval + lt_Player_Fire=time; // update lt_Player_Fire + Player_Fire(); // bum bum bum // place 1/2/3 rocket/s on matrix above the players position. The rockets will be moved by another funciton + } + } + } + if( GetAsyncKeyState( VK_ESCAPE ) & 0x8000 ){ + level_runs=false; + menu_is_displayed=true; + Show_Menu(nr_menu, highlighted_menu_element); + if(sound == true){ + PlaySound("audio\\pause.wav", NULL, SND_ASYNC); + } + Sleep(250);// Sleep(250) is important for this that would otherwise quickly swapped between game and menu and it would be very annoying + } + if( time - lt_Move_Player_Rockets >= i_Move_Player_Rockets ) { //On a well-established interval (i_Move_Player_Rockets) is moving player rockets (Move_Player_Rockets()) + lt_Move_Player_Rockets = time; + Move_Player_Rockets(i_Player_Fire); + } + if( time - lt_Move_Enemy_Rockets >= i_Move_Enemy_Rockets ) { + lt_Move_Enemy_Rockets = time; + Move_Enemy_Rockets(); + } + if( time - lt_Enemy_fire >= i_Enemy_fire ){ + lt_Enemy_fire = time; + Enemy_fire(); + } + if(level.present < 5){ // up to level 5 enemies move only horizontally + if(time - lt_Move_X_Enemy_Spaceships >= i_Move_X_Enemy_Spaceships){ + lt_Move_X_Enemy_Spaceships = time; + Move_X_Enemy_Spaceships(i_Move_X_Enemy_Spaceships); + } + } + else { // after lvl 5 enemies moves "random" + if(time - lt_Move_Rand_Enemy_Spaceships >= i_Move_Rand_Enemy_Spaceships){ + lt_Move_Rand_Enemy_Spaceships=time; + Move_Rand_Enemy_Spaceships(); + } + + if(time - lt_modif_y_limit_rand_move_enemy >= i_modif_y_limit_rand_move_enemy){ // Spaceships moves random but have a lower limit that increases periodically + lt_modif_y_limit_rand_move_enemy=time; + if(y_limit_rand_move_enemy < dim_matrix.y) + y_limit_rand_move_enemy++; + } + } + if(time - lt_Add_Bonus >= i_Add_Bonus && exists_Bonus == false ){ // regularly appears a bonus (if the rocket touches this bonus it will gives bonuses / benefits to the player (more missiles to fire with or firing innterval descrease)) + if( weapon.present < weapon.maxim || i_Player_Fire >=0.20) { + lt_Add_Bonus=time; + Add_Bonus(); + } + } + if(time - lt_Add_Bonus >= i_Remove_Bonus && exists_Bonus==true){ // but the bonus is not staying in the sky forever ... it would be too easy: D + lt_Add_Bonus=time; + Remove_Bonus(); + } + if(time - lt_Add_Malus >= i_Add_Malus && exists_Malus==false ){ // bonuses, bonuses but we need something to cancel their effect + if ( weapon.present > 0 || i_Player_Fire!=0.75) { + lt_Add_Malus=time; + Add_Malus(); + } + } + if(time - lt_Add_Malus >= i_Remove_Malus && exists_Malus==true){ + lt_Add_Malus=time; + Remove_Malus(); + } + } + else +/*MENU*/if( menu_is_displayed==true ){ + Sleep(15); + if( GetAsyncKeyState( VK_UP ) & 0x8000 ){ // W == go to the menu item above + if(sound == true){ + PlaySound("audio\\blink.wav", NULL, SND_ASYNC); + } + if(nr_elements_menu[ nr_menu ]!=0){ //When there's no menu element above the current one go to last one + if(highlighted_menu_element>0){ + highlighted_menu_element--; + } + else + highlighted_menu_element = nr_elements_menu[ nr_menu ]; + + Show_Menu( nr_menu, highlighted_menu_element ); // redisplay the menu corresponding to the new value of the variable highlighted_menu_element + Sleep(50); + } + } + if( GetAsyncKeyState( VK_DOWN ) & 0x8000 ) { + if(sound == true){ + PlaySound("audio\\blink.wav", NULL, SND_ASYNC); + } + if(nr_elements_menu[ nr_menu ]!=0){ + if(highlighted_menu_element < nr_elements_menu[ nr_menu ]){ + highlighted_menu_element++; + } + else highlighted_menu_element = 0; + Show_Menu( nr_menu, highlighted_menu_element ); + Sleep(50); + } + } + if( (GetAsyncKeyState( VK_RETURN ) & 0x8000) || ( GetAsyncKeyState( VK_SPACE ) & 0x8000 ) ){ + if(sound == true){ + PlaySound("audio\\blink.wav", NULL, SND_ASYNC); + } + Enter( nr_menu , highlighted_menu_element ); // change the current menu or make an action + } + if( GetAsyncKeyState( VK_ESCAPE ) & 0x8000 ){ // close the menu and returns to the game or go to the main menu + if(sound == true){ + PlaySound("audio\\blink.wav", NULL, SND_ASYNC); + } + system("cls"); + if( nr_menu == 0 ){ + menu_is_displayed=false; + level_runs=true; + Show_Matrix(); + } + else { + nr_menu=0; + highlighted_menu_element=0; + Show_Menu( nr_menu, highlighted_menu_element ); + } + Sleep(150); + } + } + Sleep(i_Main);// primarily affects the movement of the player + } + + if(quit==false){ // if the value of quit is false ( changed from menu ) + system("cls"); + cout<<"\n Game Over!"; + if(sound == true){ + PlaySound("audio\\gameover.wav", NULL, SND_ASYNC); + } + Sleep(1000); + if( nr_lifes<=0 && ( scor > scores_int[nr_scores] || nr_scores==0 || nr_scores<10 ) ){//check for a new high score + Add_New_scores(); + Save_scores(); + Sleep(1000); + //Load_Level(1); + } + } + Save_Game(); + system("cls"); + printf("\n Hope to see you soon"); + if(new_score_char[0]!='\0') + printf(", %s!",new_score_char); + printf("!"); + Sleep(2000); + + return 0; +} + +void Finding_y_limit_rand_move_enemy(){ //ships moves random but with lower limit (y_limit_rand_move_enemy). The limit is actually enemy spaceship from the lowest position Y coordinate + int i,j; + for(i=dim_matrix.y;i>=0;i--){ + for(j=0;j<=dim_matrix.x;j++){ + if(m[i][j]==char(4)){ + y_limit_rand_move_enemy=i; + return; + } + } + } +} +void Move_spaceship_random(int x, int y, int y_limit_rand_move_enemy){ + int rnd, ok=0,counter=1; // counter prevent the while running endlessly +//if each ship would move exactly in the first position resulting from random then would eat each other if they had stuck together. so if in 15 attempts not found a free place around them is supposed to be surrounded by other ships and has no where to move and it is left in the same spot +//i could check with 4 'if()' conditions if a vessel is able to move but I chose to leave only 15 random checks of positions, so it is possible for a ship to remain in place even if it is able to move without swallowing another ship + while(!ok && counter <= 15){ + rnd = rand()%4; // Gets values from 0 to 3 (equivalent to directions that can move each spaceship) + counter++; + switch( rnd ) { + case 0: { // V + if( x-1 >= 0 ) + if(m[y][x-1] == char(32)){ // If the Western position is free (char (32) == '') + // And if there's no players rocket on column of the possible move (WARNING: this variable sometimes is lying: from a certain level even if exists rocket this variable still remains FALSE)( for different difficulty ) + if(!exists_player_rocker[x-1]) + { + m[y][x] = char(32); // refresh the matrix in memory + Print(y,x,m[y][x]); // refresh the new move on the screen + m[y][x-1] = char(4); // refresh the matrix in memory + Print(y,x-1,m[y][x-1]); // refresh the new move on the screen + ok=1; //a move was made + } + } + else if(m[y][x-1] == char(6)){ //If in the Western position is the player spaceship + m[y][x] = char(32); // The enemy spaceship is removed and the life of player drops by 1 + Print(y,x,m[y][x]); + Decrease_Life(1); + } + break; + } + case 1: { // E + if( x+1 <= dim_matrix.x ) + if(m[y][x+1] == char(32)){ + if(!exists_player_rocker[x+1]) + { + m[y][x] = char(32); + Print(y,x,char(32)); + m[y][x+1] = char(4); + Print(y,x+1,char(4)); + ok=1; + } + } + else if(m[y][x+1] == char(6)){ + m[y][x] = char(32); + Print(y,x,m[y][x]); + Decrease_Life(1); + } + break; + } + case 2: { // S + if( y-1 >= 0 ) + if(m[y-1][x] == char(32)){ + if(!exists_player_rocker[x]) + { + m[y][x] = char(32); + Print(y,x,m[y][x]); + m[y-1][x] = char(4); + Print(y-1,x,m[y-1][x]); + ok=1; + } + } + else if(m[y-1][x] == char(6)){ + m[y][x] = char(32); + Print(y,x,m[y][x]); + Decrease_Life(1); + } + break; + } + case 3: { // N + if( y+1 <= y_limit_rand_move_enemy ) + if(m[y+1][x] == char(32)){ + if(!exists_player_rocker[x]) + { + m[y][x] = char(32); + Print(y,x,m[y][x]); + m[y+1][x] = char(4); + Print(y+1,x,m[y+1][x]); + ok=1; + } + } + + else if(m[y+1][x] == char(6)){ + m[y][x] = char(32); + Print(y,x,m[y][x]); + Decrease_Life(1); + } + break; + } + } + } +} +int X_Lowest_Enemy(){ + int distance_from_player=dim_matrix.x+1; + int x_enemy; + int cntr; + cntr=nr_enemies; + while(poz_enemy_y[nr_enemies] == poz_enemy_y[cntr]){ + if( abs(poz_enemy_x[cntr]-coord_player_spaceship.x) < distance_from_player ){ + distance_from_player=abs(poz_enemy_x[cntr]-coord_player_spaceship.x); + x_enemy=poz_enemy_x[cntr]; + } + cntr--; + } + return x_enemy; +} +void Find_poz_enemy_xy_AND_poz_player(){ // necessary function for random movement (it reduces the executation time of the random function) ... It stores the coordinates of each enemy ship and coordinates of players rockets + int i,j; + nr_enemies=-1; + for(j=0;j<=dim_matrix.x;j++){ + exists_player_rocker[j]=false; + } + + for(i=0;i<=dim_matrix.y;i++){ + for(j=0;j<=dim_matrix.x;j++){ + if(m[i][j]==char(4)){ + nr_enemies++; + poz_enemy_x[nr_enemies]=j; + poz_enemy_y[nr_enemies]=i; + } + if(m[i][j]==char(2334) && level.present>=8){ // Until Level 7 are not taken into consideration player missiles for random movement + exists_player_rocker[j]=true; + } + } + } +} +void Move_Rand_Enemy_Spaceships(){ + int i; + Find_poz_enemy_xy_AND_poz_player(); + for( i=0;i<=nr_enemies; i++ ){ + Move_spaceship_random(poz_enemy_x[i], poz_enemy_y[i], y_limit_rand_move_enemy); + } +} +void Move_Y_Enemy_Spaceships(){//vertically + + bool exists_enemy_first_line=false, exists_enemy_last_line=false; + if( direction_enemy_move_Y == down ) { // check if exists_enemy_first_line + for(i=0;i<=dim_matrix.x;i++){ + if ( m[ dim_matrix.y ][i] == char(4) ) { + exists_enemy_last_line=true; + break; + } + } + if ( exists_enemy_last_line == true ) { + //direction_enemy_move_Y = up; // originally thought to move up when reach the bottom line but then I changed up so that when a spaceship reaches the last line will decreases player life + } + }/* + else {// because never ( direction_enemy_move_Y == up ) + for(i=0;i<=dim_matrix.x;i++){ + if ( m[0][i] == char(4) ) { + exists_enemy_first_line=true; + break; + } + } + if ( exists_enemy_first_line == true ){ + direction_enemy_move_Y = down; + } + }*/ + + if ( direction_enemy_move_Y == down) { + for(i=dim_matrix.y-1;i>=0;i--){ + for(j=0;j<=dim_matrix.x;j++){ + if(m[i][j]==char(4)){ + switch (m[i+1][j]) { + case char(32) : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i+1][j]=char(4); + Print(i+1,j,char(4)); + break; + } + case '*' : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i+1][j]=char(4); + Print(i+1,j,char(4)); + break; + } + case char(6) : {//♠ + m[i][j]=char(32); + Delete_Character(i,j); + Decrease_Life(1); + break; + } + case char(2334):{//▲ + m[i][j]=char(32); + Delete_Character(i,j); + m[i+1][j]='*'; + Print(i+1,j,char(4)); + break; + } + case char(2335):{//▼ + m[i][j]=char(32); + Delete_Character(i,j); + m[i+1][j]='*'; + Print(i+1,j,char(4)); + break; + } + } + } + } + } + }/* + else {// because never ( direction_enemy_move_Y == up ) + for(i=1;i<=dim_matrix.y;i++){ + for(j=0;j<=dim_matrix.x;j++){ + if(m[i][j]==char(4)){ + switch(m[i-1][j]) { + case char(32) : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i-1][j]=char(4); + Print(i-1,j,char(4)); + break; + } + case '*' : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i-1][j]=char(4); + Print(i-1,j,char(4)); + break; + } + case char(6) : { + m[i][j]=char(32); + Delete_Character(i,j); + Decrease_Life(1); + break; + } + case char(2334) : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i-1][j]='*'; + Print(i-1,j,'*'); + break; + } + case char(2335) : { + m[i][j]=char(32); + Delete_Character(i,j); + m[i-1][j]='*'; + Print(i-1,j,'*'); + break; + } + } + } + } + } + }*/ +} +void Move_X_Enemy_Spaceships( double &i_Move_X_Enemy_Spaceships ){ //horizontally Move_X_Enemy_Spaceships + int i,j; + bool direction_was_changed=false;// when direction_was_changed=true i_Move_X_Enemy_Spaceships descrease and enemy go down + + switch (direction_enemy_move_x){//Looking for alien ship on the bottom line (if exists life decreases) + verify if exists enemy at lateral edges and change direction if they are. + case rright : { + for(i=0;i<=dim_matrix.x;i++){ + if(m[dim_matrix.y][i]==char(4)){ + m[dim_matrix.y][i]=char(32); + Print(dim_matrix.y,i,char(32)); + Decrease_Life(1); + break; + } + if( m[i][dim_matrix.x] == char(4) && i<= dim_matrix.y){ // O "smecherie" pt a nu mai face un alt for + direction_was_changed = true; + } + } + if( direction_was_changed == true ) { + direction_enemy_move_x = lleft; + if(level.present>=2){ + Move_Y_Enemy_Spaceships(); + } + if(i_Move_X_Enemy_Spaceships - 0.10 >= 0.05){ + i_Move_X_Enemy_Spaceships-=0.10; + } + } + break; + } + case lleft : { + for(i=0;i<=dim_matrix.x;i++){ + if(m[dim_matrix.y][i]==char(4)){ + m[dim_matrix.y][i]=char(32); + Print(dim_matrix.y,i,char(32)); + Decrease_Life(1); + break; + } + if( m[i][0] == char(4) && i<= dim_matrix.y ){ //trick for not doing another for + direction_was_changed = true; + } + } + if( direction_was_changed == true ) { + direction_enemy_move_x = rright; + if(level.present>=2){ + Move_Y_Enemy_Spaceships(); + } + if(i_Move_X_Enemy_Spaceships - 0.10 >= 0.05){ + i_Move_X_Enemy_Spaceships-=0.10; + } + } + break; + } + } + + switch (direction_enemy_move_x){//actually horizontally move + case rright : { + for(int i=0;i<=dim_matrix.y;i++){ + for(int j=dim_matrix.x-1;j>=0;j--){ + if( m[i][j] == char (4) ) { + switch ( m[i][j+1] ) { + case (char(32)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j+1, char(4)); + m[i][j+1] = char ( 4 ); + break; + } + case (char(2334)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j+1, '*'); + m[i][j+1] = '*' ; + break; + } + case (char(2335)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j+1, '*'); + m[i][j+1] = '*'; + break; + } + case ('*') : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j+1, char(4)); + m[i][j+1] = char ( 4 ); + break; + } + case (char(6)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Decrease_Life(1); + break; + } + } + } + } + } + break; + } + case lleft : { + for(int i=0;i<=dim_matrix.y;i++){ + for(int j=1;j<=dim_matrix.x;j++){ + if( m[i][j] == char (4) ) { + switch ( m[i][j-1] ) { + case (char(32)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j-1, char(4)); + m[i][j-1] = char ( 4 ); + break; + } + case (char(2334)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j-1, '*'); + m[i][j-1] = '*' ; + break; + } + case (char(2335)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j-1, '*'); + m[i][j-1] = '*'; + break; + } + case ('*') : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Print(i,j-1, char(4)); + m[i][j-1] = char ( 4 ); + break; + } + case (char(6)) : { + m[i][j] = char ( 32 ); + Delete_Character(i,j); + Decrease_Life(1); + break; + } + } + } + } + } + break; + } + } +} +void Move_Enemy_Rockets(){ // Move down each of the enemy rockets and if a rocket reaches player life will decrease + int i,j; + for(i=dim_matrix.y;i>=1;i--){ + for(j=0;j 0 ){ + weapon.present --; + } + else { + if( i_Player_Fire != 0.75){ + i_Player_Fire = 0.75; + } + } + break; + } + case (char(219)) : { + m[i-1][j] = char(178); + Print(i-1,j,char(178)); + break; + } + case (char(178)) : { + m[i-1][j] = char(177); + Print(i-1,j,char(177)); + break; + } + case (char(177)) : { + m[i-1][j] = char(176); + Print(i-1,j,char(176)); + break; + } + case (char(176)) : { + m[i-1][j] = '*'; + Print(i-1,j,m[i-1][j]); + break; + } + case (char(32)) : { + m[i-1][j]=char(2334); + Print(i-1,j,char(2334)); + break; + } + } + } + case (char('*')) : { + m[i][j]=' '; + Print(i,j,char(32)); + } + } + } + } +} +void Move_Player_Spaceship(char direction_move_player){ // Move_Player_Spaceship to S,N,V,E ( ~S,W,A,D ) + switch (direction_move_player) { + case 'A': { + if(coord_player_spaceship.x > 0){ // to not get out of the matrix surface + if(m[coord_player_spaceship.y][coord_player_spaceship.x-1]==char(4) || m[coord_player_spaceship.y][coord_player_spaceship.x-1]==char(2335) || m[coord_player_spaceship.y][coord_player_spaceship.x-1]==char(2334) ){ // daca se atinge o spaceship extraterestra + // Cases where spaceship meets a rocket or an enemy + Decrease_Life(1); + } + else + if(m[coord_player_spaceship.y][coord_player_spaceship.x-1]!=char(219) && m[coord_player_spaceship.y][coord_player_spaceship.x-1]!=char(178) && m[coord_player_spaceship.y][coord_player_spaceship.x-1]!=char(177) && m[coord_player_spaceship.y][coord_player_spaceship.x-1]!=char(176)){ + // otherwise simply move to the right + Delete_Character(coord_player_spaceship.y,coord_player_spaceship.x); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(32); + coord_player_spaceship.x--; + Print(coord_player_spaceship.y,coord_player_spaceship.x,char(6)); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(6); + } + } + break; + } + + case 'S': { + if(coord_player_spaceship.y < dim_matrix.y){ + if(m[coord_player_spaceship.y+1][coord_player_spaceship.x]==char(4) || m[coord_player_spaceship.y+1][coord_player_spaceship.x]==char(2334) || m[coord_player_spaceship.y+1][coord_player_spaceship.x]==char(2335)){ + Decrease_Life(1); + } + else + if(m[coord_player_spaceship.y+1][coord_player_spaceship.x]!=char(219) && m[coord_player_spaceship.y+1][coord_player_spaceship.x]!=char(178) && m[coord_player_spaceship.y+1][coord_player_spaceship.x]!=char(177) && m[coord_player_spaceship.y+1][coord_player_spaceship.x]!=char(176)){ + Delete_Character(coord_player_spaceship.y,coord_player_spaceship.x); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(32); + coord_player_spaceship.y++; + Print(coord_player_spaceship.y,coord_player_spaceship.x,char(6)); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(6); + } + } + break; + } + + case 'D': { + if(coord_player_spaceship.x < dim_matrix.x){ + if(m[coord_player_spaceship.y][coord_player_spaceship.x+1]==char(4) || m[coord_player_spaceship.y][coord_player_spaceship.x+1]==char(2334) || m[coord_player_spaceship.y][coord_player_spaceship.x+1]==char(2335)){ + Decrease_Life(1); + } + else + if(m[coord_player_spaceship.y][coord_player_spaceship.x+1]!=char(219) && m[coord_player_spaceship.y][coord_player_spaceship.x+1]!=char(178) && m[coord_player_spaceship.y][coord_player_spaceship.x+1]!=char(177) && m[coord_player_spaceship.y][coord_player_spaceship.x+1]!=char(176)){ + Delete_Character(coord_player_spaceship.y,coord_player_spaceship.x); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(32); + coord_player_spaceship.x++; + Print(coord_player_spaceship.y,coord_player_spaceship.x,char(6)); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(6); + } + } + break; + } + + case 'W': { + if(coord_player_spaceship.y > dim_matrix.y-3){ + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x]==char(4) || m[coord_player_spaceship.y-1][coord_player_spaceship.x]==char(2334) || m[coord_player_spaceship.y-1][coord_player_spaceship.x]==char(2335) ){ + Decrease_Life(1); + } + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x]!=char(219) && m[coord_player_spaceship.y-1][coord_player_spaceship.x]!=char(178) && m[coord_player_spaceship.y-1][coord_player_spaceship.x]!=char(177) && m[coord_player_spaceship.y-1][coord_player_spaceship.x]!=char(176)){ + Delete_Character(coord_player_spaceship.y,coord_player_spaceship.x); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(32); + coord_player_spaceship.y--; + Print(coord_player_spaceship.y,coord_player_spaceship.x,char(6)); + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(6); + } + } + break; + } + } +} + +void Fire_Rocket(int i,int j,char rocket){// i could integrate this function in Player_Fire() function BUT because the player can shoot 2-3 missiles once I preferred to do like that + if( i>=0 && i<=dim_matrix.y && j>=0 && j<=dim_matrix.x){ + switch (m[i][j]) { + case char(32) : { + m[i][j]=rocket; + Print(i,j,m[i][j]); + break; + } + case char(2335) : { + m[i][j]='*'; + Print(i,j,m[i][j]); + break; + } + case char(2334) : { + m[i][j]='*'; + Print(i,j,m[i][j]); + break; + } + case char(219) : { + m[i][j]=char(178); + Print(i,j,m[i][j]); + break; + } + case char(178) : { + m[i][j]=char(177); + Print(i,j,m[i][j]); + break; + } + case char(177) : { + m[i][j]=char(176); + Print(i,j,m[i][j]); + break; + } + case char(176) : { + m[i][j]='*'; + Print(i,j,m[i][j]); + break; + } + } + } +} +void Enemy_fire(){ // shoot only aliens from the bottom line for not to happen to destroy themselves + for(int i=dim_matrix.y; i>=0; i--) { + for(int j=0;j<=dim_matrix.x; j++){ + if( m[i][j] == char (4) ){ + for(int k=0; k <= dim_matrix.x; k++ ) { + if( coord_player_spaceship.x+k <= dim_matrix.x ){ + if( m[i][coord_player_spaceship.x+k] == char(4) ){ + if(i+1<=dim_matrix.y){ + if( m[i+1][coord_player_spaceship.x+k] == char(32) ){ + Fire_Rocket(i+1, coord_player_spaceship.x+k, char(2335)); + i=-1; + j=dim_matrix.x+1; + k=dim_matrix.x+1; + break; + } + } + } + } + if( coord_player_spaceship.x-k >= 0 ){ + if( m[i][coord_player_spaceship.x-k] == char(4) ){ + if(i+1<=dim_matrix.y){ + if( m[i+1][coord_player_spaceship.x-k] == char(32) ){ + Fire_Rocket(i+1, coord_player_spaceship.x-k, char(2335)); + i=-1; + j=dim_matrix.x+1; + k=dim_matrix.x+1; + break; + } + } + } + } + } + } + } + } +} +void Player_Fire(){ + if(sound == true){ + PlaySound("audio\\kick.wav", NULL, SND_ASYNC); + } + switch(weapon.present){ + case 0: {// 1 rocket pop-up + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x, char(2334)); + break; + } + case 1: {// 2 rockets pop-up + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x-1, char(2334)); + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x+1, char(2334)); + break; + } + case 2: {// 3 rockets pop-up + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x-1, char(2334)); + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x, char(2334)); + Fire_Rocket(coord_player_spaceship.y-1,coord_player_spaceship.x+1, char(2334)); + break; + } + } +} + +void Show_Menu( int nr_menu, int highlighted_menu_element){// Each menu has the name elements saved in another array and has an identification number(nr_menu) . So 0 is the main menu with items saved in the matrix: menu [] [], etc. + system("cls"); + switch( nr_menu ){ + case (0) : { // main menu + cout<<"\n Main Menu \n\n\n"; + for(i = 0; i<= nr_elements_menu[ nr_menu ] ; i++) {// Display the main menu items + cout<<" "; + for(j=0; j<=strlen(menu[i]);j++){ + cout<>cheat_entered; + cheat_match=false; + for(int i=0;i<=nr_cheats;i++){ + if( strcmp ( cheats[i],cheat_entered ) == 0 ){ + switch (i){ + case 0: { + nr_lifes+=5; + cout<<" Life +5 \n" ; + break; + } + case 1: { + scor+=100; + cout<<" Score +100 \n"; + break; + } + case 2: { + if(weapon.present < weapon.maxim){ + weapon.present++; + cout<<" You have a new wapon \n"; + } + break; + } + case 3: { + Add_Bonus(); + GotoXY(9,20); + cout<<" +Bonus!\n"; + break; + } + } + cheat_match=true; + } + } + if(!cheat_match){ + cout<<"\n Ati gresit codul!"; + } + Sleep(1250); + nr_menu=1; + highlighted_menu_element=1; + Show_Menu(nr_menu,highlighted_menu_element); + break; + } + case 3 : {// modificare leveluri + nr_menu=4; + highlighted_menu_element=0; + Show_Menu(nr_menu , highlighted_menu_element); + Sleep(200); + break; + } + case 4 : {//back + nr_menu=0; + highlighted_menu_element=0; + Show_Menu( nr_menu, highlighted_menu_element ); + break; + } + } + break; + } + + case 2 : { // high scores + switch (highlighted_menu_element) { + case 0 : {//Reset high scores + FILE *file; + file = fopen("files\\Higscores.txt","w"); + fprintf(file,"0"); + fclose(file); + Load_scores(); + Show_Menu(nr_menu,highlighted_menu_element); + break; + } + case 1 : {//Back + nr_menu = 0 ; + highlighted_menu_element = 0 ; + Show_Menu(nr_menu,highlighted_menu_element); + break; + } + } + break; + } + + case 3 : { // instructions + switch (highlighted_menu_element) { + case 0 : { + nr_menu = 0 ; + highlighted_menu_element = 3 ; + Show_Menu(nr_menu,highlighted_menu_element); + Sleep(200); + break; + } + } + break; + } + + case 4 : { //customize levels + switch ( highlighted_menu_element ) { + case 10 : {// back + nr_menu=1; + highlighted_menu_element=3; + Show_Menu( nr_menu, highlighted_menu_element); + break; + } + default : {// from case 0 to 9 + Customize_Level( highlighted_menu_element +1 ); + nr_menu=1; + highlighted_menu_element=3; + Show_Menu( nr_menu, highlighted_menu_element); + break; + } + } + } + break; + } +} +void Load_scores(){ // Read from file Higscores.txt + int aux; // scores_char [n] -> name of the player n + // scores_char [n] -> score of the player n + FILE *file; + file = fopen("files\\Higscores.txt","r"); + fscanf(file, "%d", &nr_scores); // Firs read number of elements + for(i=1;i<=nr_scores;i++){ + fscanf(file, "%d", &aux); + j=0; // counter + fscanf(file, "%c", &ch);// read char by char + while ( ch!='=' ){ // until '=' . After = follows score value + scores_char[aux][j]=ch; + j++; + fscanf(file, "%c", &ch); + } + fscanf(file, "%d", &scores_int[i]); // read score value + } + fclose(file); +} +void Save_scores(){ + FILE *file; + file = fopen("files\\Higscores.txt", "w"); + if(nr_scores>10) + nr_scores=10; + fprintf(file, "%d\n", nr_scores); + for(i=1;i<=nr_scores;i++){ + fprintf(file, "%d ", i); + for ( j=0;j<=strlen( scores_char[i] ); j++ ){ + fprintf(file, "%c", scores_char[i][j]); + } + fprintf(file, " = %d\n", scores_int[i]); + } + fclose(file); +} +void Show_scores(){ // Displays saved scores + if(nr_scores==0){ // IF nr_scores = 0 ( there's no saved score) + cout<<"\n Wasn't recorded any score ! "; + } + else { // nr_scores!=0 + for( i=1;i<=nr_scores;i++){ + cout<<" "<1; k--){ + if( scores_int[k]>scores_int[k-1]) + { + sorted=false; + Swap_scores( k, k-1 ); // swaps value of scores and names of the players + } + } + } +} +void Add_New_scores(){ // read and save name of the player and the new score + system("cls"); + + cout<<"\n Congratulations! \n You have a record score ! \n"; + Sleep(1000); + cout<<" What is your name ? \n"; + fflush(stdin); + cin>>new_score_char; + int counter=-1; + + while(new_score_char[++counter]==' ' && counter10) + nr_scores=10; + Load_Level(1); + Save_Game(); +} + +void Show_Matrix(){ + system("cls"); // clear screen + + GotoXY(0,dim_matrix.x + 2); // print current level + printf(" Level: %d" , level.present ) ; + GotoXY(2,dim_matrix.x + 2); // print score + printf(" Score : %d" , scor ); + GotoXY(4,dim_matrix.x + 2); + if(nr_lifes>1){ + printf(" You have %d lifes! " , nr_lifes ); + } + else { + printf(" You have left just one life! " ); + } + + GotoXY(0,0);// to display the matrix from (0,0) + for(i=0;i<=dim_matrix.y;i++){ + cout<<" "; + for(j=0;j<=dim_matrix.x;j++ ){ + cout<0) + step-=1; + GotoXY(dim_matrix.y +1,dim_matrix.x + 2); + printf(" step = %d", step); + } + if( GetAsyncKeyState( VK_DELETE ) & 0x8000 ) { + for(int k=0;k<=dim_matrix.y;k++){ + for(int l=0;l<=dim_matrix.x;l++){ + m[k][l]=char(32); + Print(k,l,char(32)); + } + } + coord_player_spaceship.y=yspaceship; + coord_player_spaceship.x=xspaceship; + m[coord_player_spaceship.y][coord_player_spaceship.x]=char(6); + Print(coord_player_spaceship.y,coord_player_spaceship.x,char(6)); + Sleep(100); + } + if( ( GetAsyncKeyState( 'W' ) & 0x8000 ) || ( GetAsyncKeyState( VK_UP ) & 0x8000 ) ){ + if(y>0) { + y-=step; + GotoXY(y,x); + } + } + if( ( GetAsyncKeyState( 'S' ) & 0x8000 ) || ( GetAsyncKeyState( VK_DOWN ) & 0x8000 ) ){ + if(y0){ + x-=step; + GotoXY(y,x); + } + } + if( ( GetAsyncKeyState( 'D' ) & 0x8000 ) || ( GetAsyncKeyState( VK_RIGHT ) & 0x8000 ) ){ + if(x scores_int[nr_scores] || nr_scores==0 || nr_scores<10 ) {// check for new h score + Sleep(2500); + Add_New_scores(); + Save_scores(); + } + Sleep(2500); + } + else {// next level + if(sound == true){ + PlaySound("audio\\stage_clear.wav", NULL, SND_ASYNC); + } + Sleep(2500); + level.present++; + level_was_changed=true; + Load_Level(level.present); + Show_Matrix(); + Sleep(1000); + } +} + +void Add_Score(int bonus){ + if(sound == true){ + PlaySound("audio\\fireworks.wav", NULL, SND_ASYNC); + } + scor+=bonus; + GotoXY(2,dim_matrix.x+10);// refresh the score on the screen + cout<1){ + printf(" You have %d lifes! " , nr_lifes ); + } + else { + if(nr_lifes==1){ + printf(" You have left just one life! " ); + } + else + printf(" You run out of lives! " ); + } + for(int i=0;i<=9;i++){// blinking effect + Sleep(65); + if( i%2==0 ){ + GotoXY(coord_player_spaceship.y,coord_player_spaceship.x); + printf(" "); + } + else { + GotoXY(coord_player_spaceship.y,coord_player_spaceship.x); + printf("%c",char(6)); + } + } +} + + +void Auto_Play(double *time, double *i_Player_Fire, double *lt_Player_Fire ) +{ + bool exists_enemy_spaceship=false;// if on column of the player exists enemy spaceship + bool exists_enemy_rocket_x_player=false;//if on column of the player exists enemy rocket + bool exists_block=false; + + + if(!exists_Bonus){ + if(level.present>=6){ + Find_poz_enemy_xy_AND_poz_player(); + if( X_Lowest_Enemy() < coord_player_spaceship.x ){ + if(m[coord_player_spaceship.y][coord_player_spaceship.x-1]==char(32)) + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x-1]!=char(2335)) + if(m[coord_player_spaceship.y-2][coord_player_spaceship.x-1]!=char(2335)) + Move_Player_Spaceship('A'); + } + if( X_Lowest_Enemy() > coord_player_spaceship.x ){ + if(m[coord_player_spaceship.y][coord_player_spaceship.x+1]==char(32)) + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x+1]!=char(2335)) + if(m[coord_player_spaceship.y-2][coord_player_spaceship.x+1]!=char(2335)) + Move_Player_Spaceship('D'); + } + if( X_Lowest_Enemy() == coord_player_spaceship.x ){ + if(*time-*lt_Player_Fire >= *i_Player_Fire) { // time present - last time fired > shooting interval + *lt_Player_Fire=*time; + Player_Fire(); // bum bum bum + } + } + } + else { + exists_enemy_spaceship=false; + exists_enemy_rocket_x_player=false; + exists_block=false; + for( int i=0; i<=dim_matrix.y && !exists_block ; i++ ){ // check for value of the var exists_enemy_spaceship && exists_block && exists_enemy_rocket_x_player + if(m[i][coord_player_spaceship.x] == char(219)||m[i][coord_player_spaceship.x] == char(178)||m[i][coord_player_spaceship.x] == char(177)||m[i][coord_player_spaceship.x] == char(176)) + exists_block=true; + if( m[i][coord_player_spaceship.x] == char(4) ){ + exists_enemy_spaceship=true; + if(!exists_block){ + if(*time-*lt_Player_Fire >= *i_Player_Fire) { // time present - last time fired > shooting interval + *lt_Player_Fire=*time; + Player_Fire(); // bum bum bum + } + } + } + if(m[i][coord_player_spaceship.x] == char(2335))// enemy rocket + {// avoid enemy rocket if it is classified as dangerous + exists_enemy_rocket_x_player=true; + if(i>=coord_player_spaceship.y-5){ + if(weapon.present==1){ + if( m[coord_player_spaceship.y][ coord_player_spaceship.x+1] == char(32) ){ + Move_Player_Spaceship('D'); + if(!exists_block){ + if(*time-*lt_Player_Fire >= *i_Player_Fire) { // time present - last time fired > shooting interval + *lt_Player_Fire=*time; + Player_Fire(); // bum bum bum + } + } + } + else + if( m[coord_player_spaceship.y][ coord_player_spaceship.x+1] == char(32) ){ + Move_Player_Spaceship('A'); + if(!exists_block){ + if(*time-*lt_Player_Fire >= *i_Player_Fire) { // time present - last time fired > shooting interval + *lt_Player_Fire=*time; + Player_Fire(); // bum bum bum + } + } + } + } + } + } + } + if(exists_enemy_spaceship==false){// if on player column is not a enemy move left or right to the most nearest + for(int i=0; i<=dim_matrix.x; i++){ + for(int j=0; j<=dim_matrix.y; j++){ + if( coord_player_spaceship.x+i <= dim_matrix.x ){ + if( m[j][ coord_player_spaceship.x+i ] == char(4) ){ + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x+1]!=char(2335)) + if(m[coord_player_spaceship.y-2][coord_player_spaceship.x+1]!=char(2335)) + if(m[coord_player_spaceship.y][coord_player_spaceship.x+1]==char(32)){ + Move_Player_Spaceship('D'); + i=dim_matrix.x+1; + j=dim_matrix.y+1; + } + } + } + if( coord_player_spaceship.x-i >= 0){ + if( m[j][ coord_player_spaceship.x-i] == char(4) ){ + if(m[coord_player_spaceship.y-1][coord_player_spaceship.x-1]!=char(2335)) + if(m[coord_player_spaceship.y-2][coord_player_spaceship.x-1]!=char(2335)) + if(m[coord_player_spaceship.y][coord_player_spaceship.x-1]==char(32)){ + Move_Player_Spaceship('A'); + i=dim_matrix.x+1; + j=dim_matrix.y+1; + } + } + } + } + } + } + } + } + else {//if exists bonus go and get it + int corectaree=0; + if(weapon.present==1){ + if( + direction_enemy_move_x==lleft) + corectaree=1; + else + corectaree=-1; + } + if( coord_player_spaceship.x==bonus.x+corectaree ){ + if(*time-*lt_Player_Fire >= *i_Player_Fire) { // time present - last time fired > shooting interval + *lt_Player_Fire=*time; + Player_Fire(); // bum bum bum + } + } + else{ + if(coord_player_spaceship.xd) + return c; + return d; +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..e69de29 diff --git a/main.o b/main.o new file mode 100644 index 0000000..360a062 Binary files /dev/null and b/main.o differ diff --git a/obj/Debug/main.o b/obj/Debug/main.o new file mode 100644 index 0000000..777ccfc Binary files /dev/null and b/obj/Debug/main.o differ diff --git a/obj/Debug/resources.res b/obj/Debug/resources.res new file mode 100644 index 0000000..04dd7d0 Binary files /dev/null and b/obj/Debug/resources.res differ diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..b4febbb --- /dev/null +++ b/resource.h @@ -0,0 +1 @@ +#define IDR_SOUND 1 diff --git a/resources.rc b/resources.rc new file mode 100644 index 0000000..728dcf6 --- /dev/null +++ b/resources.rc @@ -0,0 +1,2 @@ +#include "resource.h" +IDR_SOUND WAVE "audio\\gameover.wav"