Jump to content

Item collection


razzmattack
 Share

Recommended Posts

I've been following this tutorial to create my first game in html. So far its been pretty great, everything seems to work just fine. Now that i've reached the end of the tutorial i've been modifying the game made to be more interesting. I'm trying to do two things and for the life of me I can't seem to figure out how to code it correctly.

 

1. This is a item collection game, but the tutorial only shows how to get the base number of items to spawn for points. Is there a way I can get more items to spawn as the old ones are collected and to cap it at a certain score?

 

2. As the score goes up i'd like to display messages. Currently I have been trying to use if(score == "score number here") with little success.

 

I was hoping to get some directions on the matter, thanks!

Link to comment
Share on other sites

Welcome to the community!

 

1. It depends how you want those new items to spawn. Maybe when the player grabs an item, another item spawns somewhere else? What are you thinking?

 

2. Try using the greater than operator and a number instead of a string:

if (score >= 1000) {  // Do something here...}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...