• Advertisement
Sign in to follow this  

Unity [web] Creating a web based strategy game

This topic is 2278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all!
This is my first post here on this community so I hope you will treat me nice tongue.gif

I'm a programmer and has very good knowledge in C# and SQL, but now on my spare time i was thinking of creating a game. I have created some small games in XNA before but this time I want to create a web based game forcing me to learn more programing languages.

I was thinking about using HTML and javascript, asp.net and mssql. I got myself all applications and servers needed for this task.

I have started (using pen and paper) to draw out the outlines for my game and how it will work basically.
My knowledge in html is about 3 on a scale to 10 and in javascript 2 on a scale to 10 but that is not something that will stop me (Google is my best friend biggrin.gif)

So now to my questions:

I was planning on creating a simple strategic game. I know there are lots of these types of games already but this is meant as a learning scenario for me.
The game itself should be about gather recources over time, buildning armies, attacking other players and so on, but not realtime game.

I want it to be based on time, let me show you an example:

The user should gain resource over time, lets say 10 gold each 15 min for example.
The player should also gain soldiers over time.

When the player choose to attack anther player, the attack will not be imminent. It should be delayed for let say 2 hrs.

So my question here is how will i handle this in code. I mean, the user will probably not sit and wait with the browser open until the attack, so this needs to be handled elswhere but how?

(1) Do i need to build some type of server application that pools the db to see if an attack should be executed or how should i approach this?

(2) How can i trigger events based on the time? For instance the resources, it should add resoucers to the player each xx min. Its easy when the user goes online i can calculate the amount by finding out how long the user been offline and then add the right amount. But when the user is online how will i add the resources? Using java
or what?

So these are my first question but more will come, rest assure tongue.gif

// Mjurfen

Share this post


Link to post
Share on other sites
Advertisement
Hey

I been looking thought your post and they are realy good questions to be asking, I am not sure of the anwser when it comes to asp.net, All i know is that using php you can create this timing effect using whats called a CRON job, this is a job done by the server anytime you set it to, So for example you could set it to go every min, and make it so that in your database you have min and hours, so every min the mins will + 1 and every 60mins the hours will plus 1.

This would make it so that you can exacute any command you wish to after any amount of time.

I have created textbased games using PHP, MySQL, HTML, Javascript, JQuery, AJax

Please feel free to email with any other questions jamienicholls1992@live.co.uk

Hope this helps

Share this post


Link to post
Share on other sites

Hey

I been looking thought your post and they are realy good questions to be asking, I am not sure of the anwser when it comes to asp.net, All i know is that using php you can create this timing effect using whats called a CRON job, this is a job done by the server anytime you set it to, So for example you could set it to go every min, and make it so that in your database you have min and hours, so every min the mins will + 1 and every 60mins the hours will plus 1.

This would make it so that you can exacute any command you wish to after any amount of time.

I have created textbased games using PHP, MySQL, HTML, Javascript, JQuery, AJax

Please feel free to email with any other questions jamienicholls1992@live.co.uk

Hope this helps



Hi and thank you for your reply!
Well it's a start, i googled the CRON and added "ASP.NET" and found this article here. Maybe thats what I'm looking for....

I will most likely keep your mail adress for further assistance if you dont mind!

I have noticed that a lot of people are using PHP, sadly though I have ZERO experience with PHP sad.gifsad.gif tongue.gif

Share this post


Link to post
Share on other sites
PHP is easy to use and i dont mind helping, i start PHP 2 years ago, i dont say i am expiranced yet, but i can create a text based game, for example

<?PHP
$MySQL = mysql_connect('localhost', 'user', 'pass');
$MySQL = mysql_select_db("name", $MySQL);
if(!$MySQL){die(mysql_error());}
?>


That is all you need to connect to a mysql database and then to do a query it mysql_query("SELECT * FROM user WHERE id='1'");

Yea keep the email and email me if you want help with anything

Share this post


Link to post
Share on other sites
Sounds like it's a classic "tick based" web game.

Yes, you probably do need to have some process which periodically processes the "ticks". In Unix this would be a "cron" job, however, it is also possible to run such jobs in MSWindows from the event scheduler or by some other means (at a push you can have a console app which just does a lot of sleeping between ticks).

The normal architecture for such a game is:

* Web UI reports the "current state" of the game, and allows players to register an "intention" to do something the following tick, maybe the amount of resources to spend on various tasks, trade with or attack another player etc.
* "Tick processor" which processes all the "intentions" each tick, and adds resources etc (e.g. resources acquired by mining, farming), handles battles, character movement, etc, and updates all the "current state" tables

Which is pretty straightforward. You just have two sets of tables "state" and "intention".

There are a few tricky bits, such as how to prevent problems where players are trying to view / update things during the "tick" - they could simply be temporarily locked out.

The game design (and UI design, graphics design etc) is likely to be much more complicated than the actual technical basis for the way such games work. They're generally pretty fun and attract a decent niche audience if done well.

Share this post


Link to post
Share on other sites

Sounds like it's a classic "tick based" web game.

Yes, you probably do need to have some process which periodically processes the "ticks". In Unix this would be a "cron" job, however, it is also possible to run such jobs in MSWindows from the event scheduler or by some other means (at a push you can have a console app which just does a lot of sleeping between ticks).

The normal architecture for such a game is:

* Web UI reports the "current state" of the game, and allows players to register an "intention" to do something the following tick, maybe the amount of resources to spend on various tasks, trade with or attack another player etc.
* "Tick processor" which processes all the "intentions" each tick, and adds resources etc (e.g. resources acquired by mining, farming), handles battles, character movement, etc, and updates all the "current state" tables

Which is pretty straightforward. You just have two sets of tables "state" and "intention".

There are a few tricky bits, such as how to prevent problems where players are trying to view / update things during the "tick" - they could simply be temporarily locked out.

The game design (and UI design, graphics design etc) is likely to be much more complicated than the actual technical basis for the way such games work. They're generally pretty fun and attract a decent niche audience if done well.


You don't actually need to update at a fixed rate, you could also have the php scripts requested by the users trigger the update logic if necessary, (This however will increase page load time for the first visit and you do need a locking mechanism to prevent multiple visitors from triggering updates at the same time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By revolverolver
      Aloha,
      First time working in 3D. Not as difficult as I thought it would be although I am pretty much a complete beginner in Blender. I chose the low poly style because I like how it looks and it is a lot easier than trying to make it look realistic.
      The gameplay is pretty much all physics driven which makes it feel satisfying to play. If it looks any fun then please check it out. I could really use a review or two.
      Here are some promo codes so that you don't have to pay a dime to download it: 
      PJW7MTMWL3W3
      A4JLYRPTXMJH
      AXRKPMAT7AAY
      YMFJPTPJ9EX3
      JY3W6FNKTM6L
       
      App store link: https://itunes.apple.com/us/app/flip-trickster/id1351027839?l=en&mt=8
       
       
    • By Innoc uous
      I'm working on a space game, and I suck at art. I would love to get some help from someone who is more skilled than me. Things I need include modular space ship parts and GUI elements. Nothing too fancy, just functional so I can get a prototype put together. This could potentially become a serious project, but for now this is just a hobby project.
       
      In this video, you can see a few things I already completed
      :2018-02-24 20-08-13.flv2018-02-24 20-08-13.flv
    • By Innoc uous
      If you want to incorporate noise into your shaders, the Turbulance Library has you covered. Using code I gathered from this library, I made a cginc file that contains all you need to easily implement noise into your unity shaders. Who knows how this stuff works, but man, does it work well!
       
      https://pastebin.com/LLCUpJut
       
      Here is an example of what you can create using these noise functions.
       
    • By Nio Martinez
      I'll be buying a new laptop as my workstation for building games, Mostly 3D but not hard core. 
       
      I'm stuck at choosing between these 2 specs below. Does this really matter and if so, can some one tell my how and why it matters. 
      Choice1:
      Intel core i5-8250U (8th gen Kabylake refresh)(6 MB Smart Cache, 1.6 GHz Base with Turbo Boost up to 3.4 GHz) 4 cores 8 threads
      RAM 8 GB DDR4 (2400 MHz)
      GPU 2 GB DDR5 Nvidia MX150 256 bit
      SSD: yes
      Choice2:
      Intel core i7-7500U 2.70GHz Base Processor (4M Cache, up to 3.50 GHz Boost) 2 Cores, 4 Threads
      RAM 4 GB DDR4 (1800 MHz)
      GPU 2 GB DDR5 Nvidia GeForce 940MX 256 bit
      SSD: No
       
    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
       
  • Advertisement