Nintendo Duck Hunt Remake
Version v1.08 by Colin Ord, 2012
A personal programming project to remake the 1984 Nintendo duck hunting game for Android devices.
Once again I decided to try my hand at writing another game this time for mobile devices. I didn't have any great game ideas of my own but recently viewed a NES (Nintendo Game System) game compilation video on YouTube and the Duck Hunt caught by interest. You can't use a light gun for this of course but a steady touch will do to shoot the ducks! The game mechanics and 2D animation seemed easy enough to recreate within Basic4Android so I decided to proceeded with the game design and coding back in June, 2012.
Source Code and assets
With so many requests for information regarding how the game example was made I have decided to release the source into the public domain. The code is quite messy but should have some worth for people interested in how it was built.
Basic4Android - required.
It was originally made for an HTC wildfire - portrait orientation.
Source Code for Duck Hunt remake
Game assets for Duck Hunt remake
Logic and structure
Let's start off by saying that this was was not as easy as I thought it would be!
After some time reviewing various game videos and noting the 'simple' gameplay I started coding section snippets. These snippets are small individual stand alone code blocks used to test various actions, animations, routines etc. Once I had a working version of a snippet I would test it on my phone and if it worked as expected i would implement the code into the main game section. This would be done throughout and I probably had around 20-30 code snippets for various actions or animation tests. These ranged from a simple test for animation, using imageviews, working with sound files, controlling timers etc.
In the initial phase I managed to adapt much of the code to include important features such as game timers, image views, animations, sounds file management and learnt a lot. Unfortunately the main game code quickly spread to hundreds of lines and i I found if increasingly confusing and frustrating follow the flow of my program.
One good example of this was sinply getting the duck to fly randomly around the screen making sure it faced the correct direction in flight and be clickable (shot). An example of the thought pattern required to implement this is noted below:
- Timers: main game, 6 seconds level timer, animation and sound control timers
- Image views: cantainers to hold and manipulate the various animation bitmaps (enabled, visable, clickable)
- Counters: to control animation frames, duck and level status etc.(on, off reset, accumulative)
- Collisions: screen boundary checks so the duck stays inthe player view. (top, bottom, left, right)
- Scoring: General scoring. (Missed, hit, reset)
- Shots fired: 3 shots fired equals a lost life (count, reset)
- Random Waypoints: a waypoint system to create new duck flight paths. (x1,y1, x2,y2)
- Choose Direction Matrix: 3x3 matrix to calculate the duck direction whilst in flight.
1 2 3
8 0 4
7 6 5
e.g. 5 = SE
1 = NW,
2 = N
3 = NE
4 = E
5 = SE
6 = S
7 = SW
8 = W
- Loops: loops, counter loops, timer loops, animation loops etc.
These notes above don't even take into account other required items such as intro screen handling, buttons, how long sounds play, handling resets (resetting score, timers, shots), error checking, dog animations used throught the code for general game elements handling.
With a lot of patience and perseverence I managed to get the main body of the game working and can have a quick game of Duck shoot or use it as a showcase on my phone but it's still a long way from completion. As it stands this game will never be release in its entirety but will always be a nice small personal project that has helped me understand game coding and the core features of Basic4Android that bit more.
Unfortunately I find this type of dynamic programming very tiring and have decided to stop the game dev before it takes over all my spare time. I have enjoyed this journey into game programming again but realise that my strengths are within aplication development rather that the dynamic/logical approach required for game coding I should really concentrate my efforts on those instead.
I'm not sure if Nintendo would like me disributing their sprites and sounds used in the game so I will release a short video showing the game working (in its curent state) to showcase my efforts so far.
Basic4 Android coding features
- Created with Basic4Android
- 320x480 - full screen
- 60 fps for smooth animation.
- Animations - Duck flight (several directions), fall, dog laugh, dog holding dead duck.
- Collision checks - only for windows boundary
- clickable events - has the duck been clicked!
- Sound - Uses sound pool audio for playing quick successions sounds (frequent), e.g. gunshot
- Media player - used for longer music or infrequent sound playing.
- Uses several 'image views' for holding animations.
- Random 'waypoint' system for calculating ducks new flight direction
- Scoring system, levels, lives, points.
- Timers - Game and level timers, noise timers
- Pause routines - for slowing down animations and holding bitmaps onscreen for a short periods of time
- Intro screen with music
- Original Nintendo sprites and sound effects
Nintendo owns all game imagery and sound effects. I will not be releasing the game for profit in any way. The remake was created only as a personal project and for my own learning experience.
Duck Hunt, © 1984, Nintendo Co, LTD