Giter Club home page Giter Club logo

duckhunt-js's Introduction

DUCK HUNT JS v3.0

Play the game

This is an implementation of DuckHunt in Javascript and HTML5. It uses the PixiJS rendering engine, Green Sock Animations, Howler, and Bluebird Promises.

Rendering

This game supports WebGL and Canvas rendering via the PixiJS rendering engine.

Audio

This game will attempt to use the WebAudioAPI and fallback to HTML5 Audio if necessary. Audio is loaded and controlled via HowlerJS.

Tweening

The animations in this game are a combination of PixiJS MovieClips built from sprite images and tweens. Since PixiJS doesn't provide a tweening API, Green Sock was used.

Game Logic

The flow of this game is managed using Javascript. The main chunks of business logic are implemented as ES6 classes which are transpiled to ES5 using Babel.

Working With This Repo

  • You must have nodejs installed.
  • Clone the repo into a directory of your choice
  • cd into that directory and run npm install
  • Use npm start to start a local webserver which will make the site available at http://localhost:8080/. Cross origin errors prevent this project from being accessed in the browser with the file:// protocol. This will also trigger automatic builds and reloads of the page when changes are detected in the src directory.
  • If you want to manually cut a build of the application code run npm run build

Working With Audio and Visual Assets

This repo ships with committed dist files to make it easy for developers to get up and running. If you really want to get into some leet haxing and change the way this game looks and sounds then you'll need to work with audio and image sprites. The following tasks make that possible:

  • To rebuild audio assets use npm run audio (there is a hard dependency on ffmpeg to run this task)
  • To rebuild image assets use npm run images (there is a hard dependency on texturepacker to run this task)

Bugs

Please report bugs as issues.

Contributing

Pull requests are welcome! Please ensure code style and quality compliance with npm run lint and include any built files.

duckhunt-js's People

Contributors

dependabot[bot] avatar mattsurabian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duckhunt-js's Issues

Weapen.spread isn't used?

Hi!
I tried adjusting the spread parameter of a gun, but this doesn't seem to be used?
The duck die function looks for a click on the duck, not near.
Right?

Vendor Everything

This would make it so folks could just download the code with all deps and go without needing to NPM install and risk dependency changes breaking the game...

Clean off the dust

This project was written as a simple jQuery game and I'd like to keep it that way because it's approachable, but it could definitely be cleaned up.

Todo:

  • Tooling is redic. Can has live-reload? Grunt-dev mode? etc...
  • Deps are OLD, update to the new hotness
  • Promise chains instead of mad setTimeouts for animation sync stuff
  • General refactor for performance and brevity.
  • Bro, do you even docs?

npm run audio - command error

gulp audio

[21:54:22] Using gulpfile ~/Downloads/DuckHunt-JS-master/gulpfile.js
[21:54:22] Starting 'audio'...
[21:54:22] Starting ''...
(node:20657) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[21:54:22] '' errored after 16 ms
[21:54:22] Error: spawn ffmpeg ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
[21:54:22] 'audio' errored after 19 ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] audio: gulp audio
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] audio script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Above is error

Level 5 loading

Description:

Level 5 takes longer to load than the previous and subsequent levels. need to wait more than 5 seconds.

Steps to reproduce:

  1. Open the link https://duckhuntjs.com.
  2. Start the game.
  3. Play up to level 5.

Actual result:

Level 5 takes longer to load.

Expected result:

The level will load at the same speed as the other levels.

Additional info:

Tested on Chrome.

Change Listen IP and port

I have found in webpack.config.js I can change the port the server listens on, however it always starts up with 127.0.0.1 (localhost) as the IP to listen on. Where is the setting so I change that to another IP or 0.0.0.0 for all IPs?

Dog Retrieve Count Bug

If two ducks are killed in rapid succession or exactly at the same time the dog sprite will correctly reflect that by changing to the state where it's holding two ducks instead of one. Unfortunately the retrieve count isn't properly decremented and it pops up twice instead of once.

npm run images error

npm run images

[10:12:51] Using gulpfile ~/sites/kerstactie-2020/gulpfile.js
[10:12:51] Starting 'images'...
[10:12:51] Starting ''...
[10:12:51] '' errored after 8.22 ms
[10:12:51] ReferenceError: connect is not defined
at /Users/joris/sites/kerstactie-2020/gulpfile.js:37:11
at bound (domain.js:427:14)
at runBound (domain.js:440:12)
at asyncRunner (/Users/joris/sites/kerstactie-2020/node_modules/async-done/index.js:55:18)
at processTicksAndRejections (internal/process/task_queues.js:79:11)
[10:12:51] 'images' errored after 10 ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] images: gulp images
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] images script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

onTouch for mobile support

Hi Matt! ๐Ÿ˜ƒ

Good job on this game, we love it! :)

I see you opened an issue (#10) for mobile support:

"...and address a lot of the mobile/refactor issues all at once."

Any news on this? I tried fastclick, vclick and changed mousedown to touchstart/end but I just can't get to kill anything..

Will you be able to assist please? Hoping it's just a minor change somewhere..
Thanks so much!!

ES6 Classes

This should use ES6 classes because I've been meaning to use them on a project and now is the time.

Restart option

It would be nice if the game had a restart option after the game over splash screen.

Chaning Tree / Background per level

Hi Everyone,
So I have been editing this game and using it for practice while learning JavaScript so far I have edited it so there are 3 levels (each with different ducks, diffculty etc) I also have the sky change from day to night through the levels the only problem is now the tree / grass is annoying me as when its night the grass it still a bright green. I was wondering is there a way to change the tree / grass etc per level? If so how can this be achieved?

Cheers

Changing background each level and game completion screen

Hi Everyone,

I'm in the process of editing this game (just a little home hobbie while I try to learn JS) and have a quick question. At the moment I have 3 levels all with different characters however I want to change the background from sunrise to sunset over these 3 levels, how would I achieve this? I have a solid png image at the moment so if I could load a different png file per level that would be great! but if there is a way to change the background through hex color this way would be fine too.

Also on another note at the end of the 3 levels I want to add a firework animation with the you won screen.... any ideas?

Thank you for your time

Sniffing Glitch

There is some bug with the dog that can cause the sniff sound to never get shut off. Don't have a good repro flow though.

Adding new duck

Hi,
How can I add a new duck in the game?
I tried by creating a third image "thethirdDuck.png" with different colour & added this in style.js as

.duckC{
    background:url(images/thethirdDuck.png) 0px 0px no-repeat;
    width:76px;
    height:73px;    
    position:absolute;
    top:400px;
    left:0;
}

Lateron I added duckC in duckhunt.min.js file as follows

 releaseDucks: function () {
            for (var e = 0; e < this.level.ducks; e++) {
                var t = e % 2 === 0 ? "duckA" : "duckB": "duckC";
                this.duckMax++, this.liveDucks.push((new Duck(this.duckMax.toString(), t, this.level.speed, this.playfield)).fly())
            }
        },

but it doesn't seems to work.

Cant get gulp dev to work

Hi, i'm trying to make some little changes and i'm trying to use the command gulp dev, but it doesnt work. Throws the following error:

`[17:12:11] Using gulpfile ~/Downloads/DuckHunt-JS-master/gulpfile.js
[17:12:11] Starting 'images'...
[17:12:11] Starting 'audio'...
[17:12:11] Finished 'audio' after 33 ms
[17:12:11] Starting 'jshint'...
[17:12:11] Starting 'jscs'...
[17:12:12] Starting 'modules'...
[17:12:12] Finished 'modules' after 43 ms
[17:12:12] Starting 'watch'...
[17:12:12] Finished 'watch' after 104 ms
[17:12:12] Starting 'serve'...
[17:12:12] Finished 'serve' after 57 ms
[17:12:12] Server started http://localhost:8080
[17:12:12] LiveReload started on port 35729

events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)`

Algo i had to install TexturePacker from a deb file because npm didnt install it.
Thanks

Jank On Level Start

Got long frames at level start that can sometimes prevent the dog animation from looking right.

Live Deployment - PORT Timeout

Hey! Not an issue with your code at all just wondering if you had any tips to get this deployed on Heroku. I'm getting a port timeout error saying it can't bind to the port. I'm not familiar with Webpack so I'm a little lost here. Reskinning the game with different characters for a fun side project :). Thanks!

Asset licenses?

Are your assets licensed the same way as your code, or differently?

Bring back level creation

Back in the day there was a level creator, then the game got all fancy and that went away. Bring it back. This time in a way that folks can send links to others to play their level. Bring back warning about browser crash potential and maybe put some guard rails in to prevent ridiculous usage.

Adding different characters to each level?

Hi everyone,
Im trying to add different characters to different levels (so it isnt always the same two ducks) I have created different .png files and added them to the css however not sure where in the JS script to adjust the code? Im guessing I will need an if statment using each level ID.

this is where its picking up the ducks (duckA / B) in the JS

{var e=t%2===0?"duckA":"duckB";this.duckMax++,this.liveDucks.push(new Duck(this.duckMax.toString(),e,this.level.speed,this.playfield).fly())}},
killDuck:function(t){this.levelStats.ducksKilled+=1,this.liveDucks=_(this.liveDucks).reject(function(e){return e.id===t.id}),
0===this.liveDucks.length&&this.playfield.trigger("wave:end",this.curWave)},
drawDucks:function(){var t="",e=this.level.ducks*this.curWave-this.levelStats.ducksKilled;e=e>25?25:e;

And these are the Levels

levels=[
{id:1,title:"Level 1",waves:1,ducks:10,pointsPerDuck:100,speed:2,bullets:15,time:25},
{id:2,title:"Level 2",waves:1,ducks:10,pointsPerDuck:150,speed:4,bullets:15,time:20},
{id:3,title:"Level 3",waves:1,ducks:10,pointsPerDuck:200,speed:6,bullets:15,time:18}],

I want to be able to have duckC / D on level 2 (id 2) and duckE / F on level 3 (id 3).... Can anyone help?

how to make two players

how to make two players game player1 should kill only red duck and player2 should kill black duck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.