Coding the currency

April

Gaming Engine Supporters
Hello everyone!

 
I have began general css and html work on a little pet project, a new one, and am making some progress. Super excited, but theres a few threads here and there that I keep getting snagged on. The biggest one at the moment is game currency.
 
 
Going off one of the tutorials here, I designed the best way is to start with a login system and the game currency. Following that logically next would be a store, items, inventory, and then finally the pets themselves which are going to be the biggest obstacle. 
 
 
I have decided to use php and mysql, and have been slowly learning all about them.  I have already researched login systems, and that should be easier to do as it has a lot of info online. However, currency systems in browser games are not as easy to research, so Im having a bit of an issue with them.
 
Could anyone give me a little advice on it? And some links with resources? 
Thank you
 
Last edited by a moderator:
Hi April,

Once you get your login system working and retrieving the user data (such as username) from the database, it should then be really easy to retrieve other information such as the currency. I'd suggestion creating your create account/login page first, because this will force you to implement your database connection which would be the backbone of all database communications.

To start with that, your best bet to is to check out @judda's pdo wrapper here. It does alot of the legwork for you, especially with things like security and preventing SQL injection.

 
@April You can consider the bank/current to be a lot like the user login system that you already built (most features end up following a similar pattern).

  1. Create a table (or just a field on the user's table) that will contain their current currency amount
  2. Retrieve the user's current amount of currency from the database
  3. Then whenever you are able to play with it / modify the value since it's been retrieved

You should aim to have all interactions (removing/adding money) in their own helper functions so that you aren't removing it inconsistently, which will also allow you to add functionality like a transaction log could be easy to implement.

I know I'm a little vague here, but let me know how we can help!

 
It was one of the things I forgot to add when re-installing.  It's now in the header for everyone to join!

 
Back
Top