Cornstar Week 1 – 6: Proposal

WAMP and vhosts

To be able to get the server running on my local machine at home, I’ve downloaded and installed WAMP. This was fairly simple with the default settings and it works fine. It just cannot be run after Skype as they use the same port. The way around this is to simply start WAMP first, and then run Skype.

The vhost can be configured by opening up the httpd-vhosts.conf file in the Apache’s conf/extra directory. In here you can add virtual hosts to simulate a real web server domain for each project you work on. The file in mine looks like the following:

# Assignment 1 - Cornstar
<VirtualHost *:80>
    ServerAdmin jamesheazlewood@gmail.com
    DocumentRoot "e:/wamp/www/assignment1/root"
    ServerName cornstar.localhost
    ErrorLog "e:/wamp/www/cornstar/logs/cornstar-error.log"
    CustomLog "e:/wamp/www/cornstar/logs/cornstar-access.log" common
</VirtualHost>

Notice that the DocumentRoot points to the root directory. This is a security measure as all the sensitive scripts and settings will be stored in a directory behind this one. So if someone happens to find a way to access the root directory, they will find it more difficult to get to the sensitive areas.

Setting the website up this way allows me to access and edit the website on a root URL  “cornstar.localhost” by typing that into my browser.

Folder structure

The way I intend on setting up the server will be great for security, organisation, and the MVC software pattern. This structure may be added to as I develop the site, but this is a great start.

  • www – wamp root dir
    • assignment1 – this is a sub dir where the vhosts refers to. This allows me to have multiple websites without moving files around.
      • docs – This is where resources and assignment documents will go
      • logs – this is where Apache and the website store log files
      • root – root of the domain. Typing / after the website domain will be this directory.
        • Index.php – the website runs from this file
        • css – CSS files go in here
        • js – Javascript files go in here
        • img – Images go in here
      • view – all view related files will be stored here
        • template – template files (header and footer) will be stored here. They will contain the main mark-up of the web page to avoid repetition in every page
        • pages – this is where each section of the web page is stored
      • model – all database models go in here
      • controller – all controller scripts go in here
      • conf – all configuration files like database login info and website settings goes in here

Database design

One of the very early things I like to do is create the database and play with that as it is essentially the hard drive of the game. All data about the game, users and corn information will be stored here.

The tables for the database are:

users

Name Type Notes
id int ID of the user
username Varchar 32
password Varchar 64 Encrypted as sha1 before saving
email Varchar 128 Email (checked as proper email before save)
name Varchar 128 Real name, first and last (not required)
<>country Varchar 128 Just country text
money int How much money in the bank. Will always be whole numbers.
width int Farm width
Height int Height
created datetime Date and time user was created
last_login datetime Record of the last time this user logged in

plants

Name Type Notes
id int
seed_id int Links to the seed types
user_id Int Links to which user plated this seed
planted datetime Date and time the seed was planted
harvested datetime Date and time this plant was harvested. *

* Also used to determine if this has been harvested or not. If not, this will be set to “0000-00-00 00:00:00”.

seeds

Name Type Notes
Id Int ID of this seed, used to link from other tables
name Varchar 64 Name of the seed, exmaple “Juicy Corn”
cost int Cost for planting this seed
time int Time in minutes that this takes to grow. 40 hours would be 144,000.
sell int Price this item sells for.

Database notes

The reason I’ve chosen to represent the time left on a plant growing with a date planted is because this is safer to use against hackers trying to dynamically make a plant fully grown. If they do this and send to the system that they are harvesting this plant, the system can check when the plant was actually planted, and if the time has been enough, then it can be harvested, and if not, then we decline the request.

Another table for this database could be a “Country” table. This will allow people to select their country in a drop-down and would store the country as either an ID or a country code (example: AU). However, this is not an important feature of the website, and the country field will not be required, so I’ve left it a as simple text field.

I could have also made the first and last name separate fields in the user’s table, except this sort of this is not important for such a game. If this was a database for a mailing list and you wanted to arrange the users by last name, then that’d be useful. But otherwise there is no point.

Artwork

When making games, I usually start off with assets after planning as usually someone else will do these and I can then focus fully on the programming-side of the game.
Because HTML can include buttons and other tools like select box drop-downs, I will basically only need the game board. The only artwork I’ll need for this would be 3 different animations of corn growing and dirt.

corn0001

DELICIOUS.

Leave a Reply

Your email address will not be published. Required fields are marked *