2 Replies - 474 Views - Last Post: 27 August 2013 - 10:40 AM Rate Topic: -----

#1 Jodan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-August 13

Auto update database every second? Where to start.

Posted 27 August 2013 - 08:17 AM

Hey, I wanna make a game where players build stuff, like a Field, that automatically collects grain for them.

The field would be upgradable, thus collecting X grain per second or minute.
The updates will have to be done server side to prevent easy cheats, not sure if this puts a lot of strain on the server? But a lot of other games do it, so it should be fine?

I'm just looking for a few pointers here, I have no idea where to start.
I'd be using html / php for my website with a mysql database.

Is This A Good Question/Topic? 0
  • +

Replies To: Auto update database every second? Where to start.

#2 Michael26  Icon User is online

  • DIC-head, major DIC-head
  • member icon

Reputation: 362
  • View blog
  • Posts: 1,534
  • Joined: 08-April 09

Re: Auto update database every second? Where to start.

Posted 27 August 2013 - 08:24 AM

I'm no PHP expert, but this is what i've found.
Take it with the grain of sand.

This post has been edited by Michael26: 27 August 2013 - 08:24 AM

Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5874
  • View blog
  • Posts: 12,752
  • Joined: 16-October 07

Re: Auto update database every second? Where to start.

Posted 27 August 2013 - 10:40 AM

You're thinking about this in the wrong direction. You don't need to accumulate, just calculate.

Consider, I have a "resource" defined as GrainGenerator { CreationTime, GrainPerSecond, GrainTaken }

How much grain is available is the result of DiffInSecs(Now, CreationTime) * GrainPerSecond - GrainTaken

You need only update GrainTaken when the player uses the resource.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1