473,420 Members | 3,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,420 developers and data experts.

Development of Funny H5 Game - Toy Claw

1
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ([Online Demo](http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it can inspire everyone.

![](http://rzoxndoq0.hd-bkt.clouddn.com/claw.png)

### Creativity & Design

《Toy Claw》is an online version of the popular arcade game that brings classic grabber gameplay to the mobile screen. Players can control the movement of the grabber and the grabbing action by tapping the buttons to try and grab the doll and send it to the exit successfully. The game features easy-to-understand gameplay, while also incorporating some strategic elements that add to the fun and challenge of the game.

In terms of game design, the following points were emphasized:

1. **Cute Doll Characters**: A variety of cute doll characters are designed to attract players' interest and emotion.

2. **Real Physics Simulation**: Physics simulation is used for the gripping hand movements and the doll grabbing process in the game, so that players can feel the real operation and challenges.

3. **Reward System**: In order to stimulate the player's sense of participation, a reward system is designed, for example, gold coins or props can be obtained for catching specific dolls, thus increasing the replay value of the game.

### Developing

Front-end technologies such as HTML5, CSS3 and JavaScript were mainly used in the developing.

1. **Page Layout and Style Design**: Firstly, we designed the page layout and style of the game to ensure that the game interface is beautiful and friendly. Responsive design that adapts to different screen sizes is a point that cannot be ignored.


HTML code

```html
<div id="game-container">
<div id="claw"></div>
<div id="doll"></div>
</div>
```

CSS code

```css
#game-container {
position: relative;
width: 300px;
height: 400px;
border: 1px solid #000;
overflow: hidden;
}

#claw {
position: absolute;
width: 50px;
height: 50px;
background-color: gray;
bottom: 0;
left: 125px;
}

#doll {
position: absolute;
width: 40px;
height: 40px;
background-color: pink;
top: 360px;
left: 130px;
}
```

2. **Physics simulation implementation**: In order to achieve realistic grasping actions, physics engine libraries such as Matter.js are used to simulate behaviors such as movement, collision, and grasping of the gripper.


```javascript
const Engine = Matter.Engine;
const Render = Matter.Render;
const World = Matter.World;
const Bodies = Matter.Bodies;

const engine = Engine.create();

const claw = Bodies.rectangle(x, y, width, height);
const doll = Bodies.circle(x, y, radius);

World.add(engine.world, [claw, doll]);

Engine.update(engine);
```

3. **Interaction Logic Writing**: Write JavaScript code to handle the interaction logic of the game, including grabber control, doll grabbing judgment, reward system, etc.

```javascript
const claw = document.getElementById('claw');
const doll = document.getElementById('doll');
const gameContainer = document.getElementById('game-container');

claw.addEventListener('click', () => {
claw.style.left = newPosition + 'px';

if (checkCollision(claw, doll)) {
doll.style.position = 'absolute';
doll.style.top = '0';
doll.style.left = '0';
gameContainer.appendChild(doll);
}
});

function checkCollision(element1, element2) {
}

```

4. **Interaction Logic Writing**: Write JavaScript code to handle the interaction logic of the game, including grabber control, doll grabbing judgment, reward system, etc.

### Experience and Lessons

During the development process, some valuable experiences and lessons were gained:

1. **Choose the right technology**: In the development process, it is very important to choose the right technology. For example, using physics engine library can simplify the implementation of physics simulation, using jQuery can simplify DOM operation, using Bootstrap can simplify page layout and style, etc..

2. **Focus on user experience**: User experience is an important standard to measure the goodness of a game. In the development process, we should focus on user experience, for example, whether the operation of the game is simple and easy to understand, whether the interface of the game is beautiful and friendly, and whether the feedback of the game is timely.

3. **Focus on the playability of the game**: The playability of the game is an important criterion for measuring whether a game is good or bad. In the development process, we should focus on the playability of the game, for example, whether the difficulty of the game is moderate, whether the replay value of the game is high, and whether the reward system of the game is perfect.


### Summary

Through the development of Online Catching Machine, I deeply realized the fun and challenge of H5 game development. This game not only brings entertainment to the players, but also is an exercise for me in technology and creativity.

**Note**

These examples are simplified, more optimization and refinement may be needed in actual development, such as dealing with multiple dolls, adding animation effects, adding more levels, etc.
Aug 25 '23 #1
0 5721

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Rob R. Ainscough | last post by:
MS Visual Studio Ad contained in VS Magazine. Two developers in "hip" clothing diagramming out a huge flow chart on a beach. I could NOT stop laughing at the stupidity of the ad -- "Let your...
0
by: Advertiser for `2D Games Development Central` | last post by:
New to game development? Need a headstart in creating that first game of yours? Want to meet others who share a passion for playing and creating games? Need support, but don't know where go for it?...
7
by: Benjamin Vigneaux | last post by:
Well, I'm very interested in game development, I'm just starting out though, browsing here and there for tutorials, references, etc.. and learning about the game development industry... What...
17
by: manjava | last post by:
HELLO, am developpement the mini game of arcoide on j2ME but i don't know any web site talk about the programming the game on the J2ME please if u know some url of the web talk about the begining...
0
GaryTexmo
by: GaryTexmo | last post by:
I've decided to do a series of insights based on creating a simple windows game using C# and WinForms. There are other methods of approaching this task but I've chosen to try to keep things fairly...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.