Skip to content
Open

sa #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

*.vcxproj
# Mono auto generated files
mono_crash.*

Expand Down Expand Up @@ -360,4 +360,5 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd
/ConsoleApplication1/ConsoleApplication1.vcxproj
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ConsoleApplication1/ConsoleApplication1.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>SFML-2.6.1\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>winmm.lib; opengl32.lib; freetype.lib; sfml-graphics-s.lib; sfml-window-s.lib; sfml-system-s.lib; sfml-audio-s.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>sfml-graphics.lib;sfml-window.lib;sfml-system.lib;sfml-audio.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions ConsoleApplication1/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@
unordered_map<int, vector<int>> Graph::graph;
unordered_map<int, Graph::Node> Graph::nodesInfo;



vector<vector<int>> Graph::pacmanMatrix = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0},
{0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0},
{0,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,0},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0},
{0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0},
{0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0},
{0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};


Graph::Node Graph::ConstructNode(int i, int j, int nodeSize) {
Node node;
node.x = i;
Expand Down
26 changes: 3 additions & 23 deletions ConsoleApplication1/Graph.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <SFML/Graphics.hpp>
#include <bits/stdc++.h>
#include<Bits.h>
#include <unordered_map>
#include <iostream>
using namespace std;
Expand All @@ -15,28 +15,8 @@ class Graph
static const int mapCells = 20;
static unordered_map<int, vector<int>> graph;
static unordered_map<int, Node>nodesInfo;
vector<vector<int>> pacmanMatrix = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0},
{0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0},
{0,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,0},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0},
{0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0},
{0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0},
{0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0},
{0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0},
{0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
static vector<vector<int>> pacmanMatrix;




Expand Down
94 changes: 94 additions & 0 deletions ConsoleApplication1/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,101 @@ int instruction(RenderWindow& window)
}
}

void select_checkMouseHover(RenderWindow& window, Sprite difficulty[], int numphoto, int& selectedOption) {
bool check = 0;
for (int i = 0; i < 3; i++)
{
if (difficulty[i].getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window))))
{
selectedOption = i;
check = 1;
}
}
if (check == 0)
{
selectedOption = -1;
}
}
int SelectDifficulty(RenderWindow& window) {
int selectedOption = -1;
Texture background;
Sprite bg;
background.loadFromFile("Assets/images/select difficulty.png");
bg.setTexture(background);
bg.setScale(1.9, 1);
bg.setPosition(0, 0);

Texture difficulty[3];
Sprite df[3];
difficulty[0].loadFromFile("Assets/images/select easy.png");
difficulty[1].loadFromFile("Assets/images/select medium.png");
difficulty[2].loadFromFile("Assets/images/select hard.png");

for (int i = 0; i < 3; i++)
{
df[i].setTexture(difficulty[i]);
}

while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
{
window.close();
}

if (Keyboard::isKeyPressed(Keyboard::Escape))
{
return 1000;
}

if (event.type == Event::MouseMoved)
{
select_checkMouseHover(window, df, 3, selectedOption);
}

if (event.type == Event::MouseButtonPressed) {
if (event.mouseButton.button == Mouse::Left)
{
if (selectedOption != -1)
{
return selectedOption;

}
}
}
}

window.clear();
window.draw(bg);

for (int i = 0; i < 3; i++)
{
if (selectedOption == i)
{
df[i].setScale(1.2f, 1.2f);
df[i].setPosition(400 * i + 400 - 20, 550 - 20);
df[i].setColor(i == 0 ? Color::Green : (i == 1 ? Color::Yellow : Color::Red));
}
else
{
df[i].setScale(1.f, 1.f);
df[i].setColor(Color::White);
df[i].setPosition(400 * i + 400, 550);
}

window.draw(df[i]);
}

window.display();
}
}


int Game_Play(RenderWindow& window) {
int x = SelectDifficulty(window);
Graph g;
int row = g.pacmanMatrix.size();
int col = g.pacmanMatrix[0].size();
Expand Down
Binary file added ConsoleApplication1/OpenAL32.dll
Binary file not shown.
Binary file added ConsoleApplication1/sfml-audio-2.dll
Binary file not shown.
Binary file added ConsoleApplication1/sfml-graphics-2.dll
Binary file not shown.
Binary file added ConsoleApplication1/sfml-network-2.dll
Binary file not shown.
Binary file added ConsoleApplication1/sfml-system-2.dll
Binary file not shown.
Binary file added ConsoleApplication1/sfml-window-2.dll
Binary file not shown.