The simplest way to get started would be to use inline javascript in a html file that references the latest version of the fc64js library hosted on github. Simply create a file named snake.html
and in your text editor or IDE paste in the following boilerplate:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>snake</title>
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1, maximum-scale=1" />
<script src="https://theinvader360.github.io/fc64js/lib/fc64.min.js"></script>
<script>
function romInit() {
drawText(0, 0, 'Hello World!', COL_WHT);
}
function romLoop() {
}
</script>
</head>
<body>
</body>
</html>
If you want to work offline simply download the latest version of the fc64js library and update the script src
value accordingly
If you want to keep your html and javascript separate you can replace the second script
element with e.g. <script src="./main.js"></script>
and move the script content into a separate file (e.g. main.js
)
If all has been done correctly, when you open your snake.html
file in a web browser you will be presented with a familiar greeting…
Jump to step: Introduction · Project setup · Creating the snake · Drawing the snake · Moving the snake · Throttling the speed · Input handling · Placing the fruit · Eating the fruit · Losing the game · Managing state · Playing sound effects · Bug fixing · Distribution