Skip to content
Open
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
76 changes: 76 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
body {
background-color: black;
}

.main {
background-color: white;
margin-top: 110px;
padding-left: 100px;
min-width: 1200px;
height: 500px;
position: relative;
z-index: 1;
}

#ryu {
width: 659px;
height: 494px;
}

#ryu-ready, #ryu-still, #ryu-throwing, #ryu-cool {
width: 659px;
height: 494px;
}

#ryu-ready, #ryu-throwing, #ryu-cool {
display: none;
}

#ryu-ready {
background-image: url("../images/ryu-ready-position.gif");
}

#ryu-still {
background-image: url("../images/ryu-standing-still.png");
}

#ryu-throwing {
background-image: url("../images/ryu-throwing-hadouken.png");
}

#ryu-cool {
background-image: url("../images/ryu-cool.gif");
}

#hadouken, #ryu-ready, #ryu-still, #ryu-throwing, #ryu-cool {
background-repeat: no-repeat;
}

#hadouken {
background-image: url("../images/hadouken.gif");
width: 156px;
height: 90px;
display: none;
position: absolute;
z-index: 10;
top: 170px;
left: 530px;
float: left;
}

.click {
position: absolute;
color: red;
margin-left: 550px;
margin-top: -430px;
font-size: 40px;
font-family: Bangers;
width: 600px;
}
.click p {
width: 50%;
}
.click p:last-child{
float: right;
margin-top: -20px;
}
58 changes: 58 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$(document).ready(function() {
//Variable declaration
var ryu = $("#ryu"),
ryuStill = $("#ryu-still"),
ryuReady = $("#ryu-ready"),
ryuThrowing = $("#ryu-throwing"),
ryuHadouken = $("#hadouken"),
ryuCool = $("#ryu-cool"),
hadoukenSound = $("#hadouken-sound")[0],
coolSound = $("#cool-sound")[0];


//Mouse over for ready position
ryu.mouseenter(function() {
ryuStill.hide();
ryuReady.show();
});
ryu.mouseleave(function() {
ryuReady.hide();
ryuStill.show();
});

//On mouse click trow hadouken
$("body").mousedown(function() {
ryuReady.hide();
ryuThrowing.show();
ryuHadouken.show().animate({left: "+=530px"}, 400).fadeOut("fast");
hadoukenSound.play();
});
$("body").mouseup(function() {
ryuReady.show();
ryuThrowing.hide();
ryuHadouken.hide().animate({left: "-=530px"}, 0);
});


//When X is pressed go to cool pose
$(document).keydown(function(e) {
if(e.which == 88) {
ryuStill.hide();
ryuReady.hide();
ryuHadouken.hide();
ryuCool.show();
coolSound.play();
}
});
$(document).keyup(function(e) {
if(e.which == 88) {
ryuStill.show();
ryuReady.hide();
ryuHadouken.hide();
ryuCool.hide();
coolSound.pause();
}
});


});
27 changes: 26 additions & 1 deletion main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,34 @@
<title>Streetfighter</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link href='https://fonts.googleapis.com/css?family=Bangers' rel='stylesheet' type='text/css'>
</head>
<body>

<div class="main">
<div id="ryu">
<div id="ryu-still"></div>
<div id="ryu-ready"></div>
<div id="ryu-throwing"></div>
<div id="ryu-cool"></div>
</div>
<div id="hadouken">
</div>

<div class="click"><p>Click on Ryu to make him throw a Hadouken.</p>
<p>Press and hold down the "x" key to make him strike his cool pose!</p>

</div>


</div>


<audio id="hadouken-sound" preload="auto">
<source src="sound/hadouken.mp3"></source>
</audio>
<audio id="cool-sound" preload="auto">
<source src="sound/epic.mp3"></source>
</audio>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="js/app.js"></script>
</body>
Expand Down
Loading