• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Creating a hidden object game in html5 (pseudo code)

1 post in this topic


I'm trying to create a reasonable simple hidden object (where is Waldo/Wally type game) and having some trouble creating a plan of action to create this.

What I want to do is have a starmap and ask Users to find a specific Zodiac. When a user clicks a star it should shown to be clicked and once the user believes they have the right stars selected can submit it to check if they are right or not.

My plan is to have a blank starmap and set it as the background image. I know I can use jquery to bind mouse clicks over the image. My idea than was to have a list of the correct pixle positions and check if the users click was within x radius of the right spot to verify they clicked a star. My problem is how to show the user clicked something. Right now the only way I can think of doing that is have a different image map of each star selected (plan is just to colour them in) and the rest of the map set as transparent and just overlap the background image with a selected star image (so as they keep getting overlapped the stars should be shown to be coloured in).

In a nutshell my Pseudo code is
[source lang="plain"]
pick random zodiac.
Set blank star map as background image
if mouse click
send server the spot clicked
check if spot is within X of any stars (list of correct positions)
if user clicked a star highlight/deselect star
//insert idea here how to highlight star
if user submits
check if right starts selected
If true than game isDone
if not inform user their selection is wrong
} while (isDone == false)[/source]

So just wondering if this would be the best way to go, if there is a more efficient way?

Share this post

Link to post
Share on other sites
Hello Wizuriel:

There are quite a few ways you could approch this problem, and HTML5 is unnecessary (and unless your planning on going the canvas route, irrelevent). so the direction you choose to take this in is really a matter of preference and target audience (browser support). I am going to make the assumption you are using jquery here, although any method of dom manipulation should port fine.

In the ancient days, ala the pyrimids, babalyon, the invention of the pythagoran theorem, and using tables to describe the layout of a page, the W3C oracles gifted us a tag for what they called the "image maps" (http://www.w3schools.com/tags/tag_map.asp). This is what all those "find-em" games were written in back in the 90's and early 2000's. This is probably going to yield the best browser support due to how long support for this has been around, but is riddled with its own pesks, and there are simply better ways to approch the problem provided you are not interested in support for browsers over 10 years old.

In more modern days, the approch you suggested is a little more valid, though not nearly as limited to an "image" (in fact, thats hardly your best solution). Using javascript, you can easily bind yourself to the click event of ANY element. The 1st argument to the click event contains a browser-dependent location (I believe pageX/pageY, but this is one of those things that is generally normalized by api's like jquery,mootools,or prototype which you should certainly use). You connect to this event, You can have a div with a background-image representing your star-map, or an img with a src pointing to one, or a blank div with stars as individual html sprites (positioned div's with a transparent background image that looks like a star), etc. If you have the stars as indiviual elements placed on the page, you can simply bind to THEIR click events, and you will instantly know what star they click, changing the src or background-image of the star as needed. If you are using a background image with no individual elements for stars, then you will want to take the mouseX/Y location, offset it by the parent element (the starmap)'s position, in order to get a normalized starmapX/starmapY value. You then can have a bucket with all of your stars x y and radius. Then simply calculate a hit test to see if your normalized vector would be within the circles. Regardless of which the directions you take here, you should now have the "star" that was clicked (or lack thereof).

When it comes to visually showing your selection, canvas not-withstanding, one solution would be to CREATE the stars THAT WERE SELECTED by simply adding an absolutely positioned div or image on valid click (just make sure the starmap itself is positioned, hence why using the PAGE may be a bad idea). This could be a background-transparent image that goes ON TOP of the star to show its selected, or any number of tags. Furthermore, bind to the created tags click events (on create) so that you can toggle on and off stars which were selected, which removes the element. You may want to consider using delegated events here, to cut the number of event handles down.

Constallations can then be arrays of stars, probably indexed multiple times with an index for each star it spans (allowing you to quickly derive which constallations are currently being clicked). You should also store your selected stars, along with a reference to whatever represents it, to aid in finding/clearing/deleting it later.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0