Author Topic: My project: -yet unnamed game-  (Read 5316 times)

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
My project: -yet unnamed game-
« on: December 26, 2009, 08:27:47 AM »
in this here thread i will try to update things i do.
The game is retarded, simple, and lightweight.

then why make it.. well, cuse of xmas present i got fired from my job. so i got nothing else to do.
at least i can revive my php knowledge, witch was never a deep one.

why bother posting? well, someone might find interesting info about how a game is born -or not, if i happen to not finish it or something-

about the game:

name: none yet. least interesting aspect.
genre: tick based trade and war game
graphics: nah, maybe at the end.. text links are enough for now.
aim of the game: WHATEVER you like. free to do stuff. in other words, i don't care for that now.
design: multi step development. first have a bare bone engine, then expand it.
language: php+mysql database, maybe a tiny bit of javascript.
host machine: my trusty AMD k6 with a total memory of 256 mbyte, windows xp os.
connection: Adsl, 8Mbit.

plot: You, the pilot gets fired from your job at xmas, so you buy an old space hauler, and start your own business.
plain simple.

thing is, i read others post they want to make a game, but the goal they set is rather big. I don't aim for a big thing. IF multiple users can log in, and fly around and trade at stations, i will be happy. if i can add combat between players, i will be very happy.

So, i set a rather easy target, and its bloody fine if i manage it.
some may not know, but big things start as small things. then comes evolution.

soon as there is anything to show i will post a link to my "server".
for now i struggle to install things on the old trusty-rusty box.

thats all for now. gotta go a bit couse my miss is going to bite my head off if i don't clear the snow from the yard.
post here questions if you have any, or ideas (keeeeeep it simple man, close as simple as the basic concept of the game)

thank you for reading. and have a better xmas then me.


Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #1 on: December 26, 2009, 11:17:24 AM »
uuuu what an awesomeo update.
i found the editor i will be using.
komodo edit.
has a nice lizzard as logo -thats truly all i was looking for-

thats done, and the old K6 amd show some vital sings too.
did not think its going to work, but it does. after a few years laying around in the garage.
wow.
+seems fast enough
-loud i tell ya, LOUUUUUD

meanwhile i registered a fancy domain name.
off to code a login screen.
no registration for now.
if there is going to be anything to show i will make some dummy account for those who are interested -if there will be any-

komodo is fine. has everything a hobbyst needs.
grab paper and a pencil -oh, wait, thats B/S. grab openoffice and use the spreadsheet. more comfortable to make notes in that. besides handwriting is not geek enough.



ST-Mike

  • Guest
Re: My project: -yet unnamed game-
« Reply #2 on: December 26, 2009, 11:58:04 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:52:46 PM by None »

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #3 on: December 26, 2009, 12:08:54 PM »
don't you dare to pick on that old machine, lol.
it could happen the project will never be finished.

why invest into hosting?
if i choose a free host, why struggle with FTPing files over with my super ADSL connection, when it a lot more faster via LAN ?
I can bring up at least as many reasons why this is THE PERFECT development enviroment i can get for this project.

Anyways thanks for the response. login page almost finished, then i will publish my super secret domain.
be prepared, i always use p2p networks so it may be slow as hell.
question is, is it  that critical for now?
maybe when there will be something to test, like hitting the first trade or something.
but until then.. makes no sense to get better hosting solution.

you see the thing is, aim low, manage it, and be happy.
most peeps aim high, don't manage it, then end up sad.

eeeeasy, slow, gentle.
don't rush it.




Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #4 on: December 26, 2009, 03:25:01 PM »
so login page is complete, has 2 (TWO!) nice input fields.
since i would check it against mysql, and i will post here a link to the site, obvious some retarded will try to do a mysql injection. nothing better right after xmas, right?
so even now, that i have only like 5 lines of code (FIVE lines) some sort of protection is good to have.
(ironic, isin't it?  i got a windows machine, and i seek protection.)

anyways, got a php file whit the mysql database connection details.
since i will have to connect to the database, i used require_once("./yadada.php");
for filtering user input...
well user will type a few things, so its nice to have something that can filter it for me.
javascript can do that, but... from page source code any bad guy will know the name of the page data is submitted to, nothing stopping them to simply not use my login page to submit data there, right?
I prefer server side validation for this reason.
preg_replace is the ultimate tool on thisone.
so, i have yet a nother php file, yet it is included on every page where user submitted data is processed.
this file has a function inside, i call it:
FILTER
don't ask how the name came, i know it sounds a bit strange but its brilliant.
Could have called it something like.. "User_data_filtering_tool_v0.1_beta_made_by_tellmore"
i see long long long and not quite good names for things. Many commit the error of giving a small animal a large name. anyways, when called, this function will filter things from the input text.

Code: [Select]
<?php
function filter ($text)
{
$filtered preg_replace(array('/\s\s+/','/=/','/</','/>/',), ''$text);
return 
$filtered;
}
?>


its nice, it can be expanded with a lot of things, later i could even add switches so it filters everything but numbers, and so on. but for now i simply resist the urge to do it. You know being lazy is okay, as far as you do things in a fashion  that allows to LATER ON develop the basic structure.

I started with low goals, and this function is a low goal too. no whitespace, no = or < or > in the submitted data. perfect. the usual "or = 1" will not work. it does its job (for now) and thats it.

grab the openoffice spreadsheet, put the 2 files i included into it, and add comments, describe it detailed what those files do. simple, and easy.
hmm. mind me, I'm lazy? the forum posts i made are longer than what i coded so far.
ironic,ironic, ironic..

back to work.

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: My project: -yet unnamed game-
« Reply #5 on: December 26, 2009, 04:44:33 PM »
It's quite fun to follow your updates.  :)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: My project: -yet unnamed game-
« Reply #6 on: December 26, 2009, 04:48:45 PM »
I beg for mercy... use capital letters where these should be. For non native English speaker it is difficult to read.

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #7 on: December 26, 2009, 05:14:49 PM »
Darn. I try and do my best.
You get a capital letter at the start of each sentence.

So about my php ehm .. ehm  so called "knowledge".
Was messing around a half hour by now, forgot that $_POST and é_GET has to be all the way capital letters.

Up there i shown my "trusty" (patented, copyrighted) way to filter bad content.
The page that checks login is simple as a pie.
First of all it includes file to connect to mysql.
Then includes the filtering tool.
It filters both user name, and password.
Then, it makes a query to the database.
Then it checks how many results i got.

Then comes the check.
Some may fetch the database results and compare user name and password, but it is not needed.
Code: [Select]
$result = mysql_query ("SELECT * FROM users WHERE name = '$user' AND pass = '$pass'")Something like that does the query.
Not too smart, but it does the job.
Then, we throw in our special agent.
Code: [Select]
if (mysql_numrows($result) != 1) {
    header('Location: ./index.php?error=1');
}

Is quite unlikely we would get a result of 2.
Has not so high probability that 2 users share same name and password.
At least we hope.
But, anyways, if the number of results is not equal to 1, it means the user name OR the password is incorrect, or the user did not even register. So we can redirect to the opening page.
The $error=1 is the tricky $_GET variable.
On the main page I have this fellow:
Code: [Select]
<?php
if(isset($_GET['error'])) {
echo 
"bravo! you managed to input wrong password/user name";
}
?>

Naturally it will only show up IF $_GET['error'] has any value assigned.
I don't care what value, it can be anything.
So, this is taken care of..

/mind me if i did not mention, i joined here and making my posts to give some hints to others who wish to start a game project. My solutions are not clever, not the best, but very easy to reproduce, so they are okay as an entry lvl trial./

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: My project: -yet unnamed game-
« Reply #8 on: December 27, 2009, 05:25:58 AM »
Your writing style seems so hasty it's hard for me to read it :)

"cuse of xmas present i got fired from my job" ... :-(

"I don't aim for a big thing"  yeah, at least you have a chance to actually finish it, unlike someone else :)

Some tips
Anyway - to protect your code from mysql injection you're better of with mysql_real_escape_string, it's standard function designed specificly for this issue (and so you also can insert strings with quotes)
"Filtr" is a bad name anyway, you know what it filters now, but after some time... it's better to have like MysqlFilter or whatever

"SELECT * FROM" is imho more exhausting then your ommiting fetch - it's sends a whole row of data, instead you need only "SELECT COUNT(*) FROM" and it just sends number 1 or 0

When logically is to be expected only 1 result, insert "LIMIT 1" at the end of query, otherwise MySQL will continue searching for another rows even though it already has your data and won't find any afterwards

Em... mysql_numrows works for you? I see only mysql_num_rows in manual...
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: My project: -yet unnamed game-
« Reply #9 on: December 27, 2009, 05:45:30 AM »
When logically is to be expected only 1 result, insert "LIMIT 1" at the end of query, otherwise MySQL will continue searching for another rows even though it already has your data and won't find any afterwards
Unless you make the where_field UNIQUE or PRIMARY KEY, then it stops after first row without the need for a LIMIT.
« Last Edit: December 27, 2009, 05:56:27 AM by Chris »

Offline saljutin

  • Level 22
  • *
  • Posts: 260
  • Reputation: +6/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #10 on: December 27, 2009, 05:46:28 AM »
if you use header as redirection... use exit() or die() function after it so potentional code does not get executed

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #11 on: December 27, 2009, 05:51:25 AM »
Beats me, my writing style may not be the most awesome. I agree, i'm not English.
My English knowledge is sufficient for basic communications.

Okay, there is a function in php for filtering user input. Nice, but.. magic_quotes_gpc can mess it up badly. This approach means i don't have to ever thing of magic_quotes_gpc is enabled or not. Also, it would allow me to filter say.. BAD words as user name, or anything. So i would need this feature anyways. I can be terribly wrong but hell.. could not care less honestly. I'm not an experienced developer :D

Thank You for the feedback anyways, i would like to get more and more of them as I go along the long way.

Select Count is a good idea. Depending on what I aim to do.
The processing of login -if user and password is correct- needs the data related to the user to make cookies, get the user id, etc.etc.. so I can use the result of the query with fetch array.
If i would use Select Count, I would have to query the database again.
Thats why i did it with select *.
Limiting the result to 1 is a good idea, i going to employ it.

Very useful feedback, thank you for sharing Your opinions with me.

Off to create the layout of the game interface. :D


Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #12 on: December 27, 2009, 08:30:28 AM »
I knew it, i knew it, and I KNEW it.

One may think PHP is enough alone to make a decent game.
Well, got bad news. It is not.

What I have so far is a decent login script, checks for cookies, or submitted data, uses my patented filter technology (-don't try that if you have other methods-)  but since its turn based game, something has just gotta move the game world.

On the server side it is not a problem.
I chosen an endless  loop setup. Efficiency is not a problem, total of 2 (two) user has ever been logged in. (for what reason some visits a dead empty page, i don't know but if they think its fun them let them have it.)

Would be quite idiotic to have a browser open on the server just to open the endless loop file.
It would make around absolute no sense at all.
I em not familiar with other language then php. Could use C, or something else, but why bother with it.
I have THIS:
http://www.bambalam.se/bamcompile/

oo Yes, You got it, it is going to convert the server side PHP script to a nice EXE file I can start anytime.
Great.

but..
Comes the question, hows i should supposed to make the CLIENT side update when the tick is over?
http://www.quackit.com/javascript/javascript_refresh_page.cfm

Thats the answer.
Javascript. (I don't remember why, but i hate it as it is.. But no other solution i have in my mind.)

So, our main page has a timed self refresh.
Our server side has a timed self refresh too.

A bit of brain work, and the 2 will work towards Victory.

What will happen is:
Endless loop will update things from the event table. Client will refresh page.
The problem is, it may happen poor client is already refreshing, while the server did not had time to finish yet.. Solution is easy, redirect client to a "please, wait till i refresh data" page, then re-redirect the client back to the game page.
The time it takes for the redirects is ANNOYING , but is a solution to give time to the server to refresh data.


The javascript on client side (i given a link to an example) will vait for X time to pass before refreshing the page / redirecting to please wait page.

The trick is, it must not be a static value.
So, i store the time stamp of the end of current tick in the database.
When the page loads, it will fetch this information, and CURRENT times tamp.
The difference between them is the value the javascript needs to wait before refreshing/redirecting the client.
So, this heals the problems for now.

I finished basic layout, now i'm off to make the refreshing thingy, so the game world can start.
And then will the harder part come.


ST-Mike

  • Guest
Re: My project: -yet unnamed game-
« Reply #13 on: December 27, 2009, 10:55:12 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:52:42 PM by None »

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #14 on: December 27, 2009, 12:40:02 PM »
well, if you guys keep supplying such good links, this project of mine thread will grow to a quite useful collection "quick start" guide, lol.

i will look into that daemon thing. I did not know php can do such things.

Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: My project: -yet unnamed game-
« Reply #15 on: December 27, 2009, 02:18:03 PM »
Unless you change your OS to Linux/unix you wont be able to use daemons.


I can send you pics of my cocks if you want reference.


Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: My project: -yet unnamed game-
« Reply #16 on: December 27, 2009, 03:03:26 PM »
I knew it, i knew it, and I KNEW it.

One may think PHP is enough alone to make a decent game.
Well, got bad news. It is not.

What I have so far is a decent login script, checks for cookies, or submitted data, uses my patented filter technology (-don't try that if you have other methods-)  but since its turn based game, something has just gotta move the game world.

On the server side it is not a problem.
I chosen an endless  loop setup. Efficiency is not a problem, total of 2 (two) user has ever been logged in. (for what reason some visits a dead empty page, i don't know but if they think its fun them let them have it.)

Would be quite idiotic to have a browser open on the server just to open the endless loop file.
It would make around absolute no sense at all.
I em not familiar with other language then php. Could use C, or something else, but why bother with it.
I have THIS:
http://www.bambalam.se/bamcompile/

oo Yes, You got it, it is going to convert the server side PHP script to a nice EXE file I can start anytime.
Great.

but..
Comes the question, hows i should supposed to make the CLIENT side update when the tick is over?
http://www.quackit.com/javascript/javascript_refresh_page.cfm

Thats the answer.
Javascript. (I don't remember why, but i hate it as it is.. But no other solution i have in my mind.)

So, our main page has a timed self refresh.
Our server side has a timed self refresh too.

A bit of brain work, and the 2 will work towards Victory.

What will happen is:
Endless loop will update things from the event table. Client will refresh page.
The problem is, it may happen poor client is already refreshing, while the server did not had time to finish yet.. Solution is easy, redirect client to a "please, wait till i refresh data" page, then re-redirect the client back to the game page.
The time it takes for the redirects is ANNOYING , but is a solution to give time to the server to refresh data.


The javascript on client side (i given a link to an example) will vait for X time to pass before refreshing the page / redirecting to please wait page.

The trick is, it must not be a static value.
So, i store the time stamp of the end of current tick in the database.
When the page loads, it will fetch this information, and CURRENT times tamp.
The difference between them is the value the javascript needs to wait before refreshing/redirecting the client.
So, this heals the problems for now.

I finished basic layout, now i'm off to make the refreshing thingy, so the game world can start.
And then will the harder part come.


... Why don't you just do it like everyone else? Download ezRPG script, study source codes and you will have in an instant a better and simplier solution :D

Offline Sunchaser

  • Game Owner
  • Level 22
  • *
  • Posts: 274
  • Reputation: +2/-0
  • Game Owner
    • View Profile
    • Medieval Europe
Re: My project: -yet unnamed game-
« Reply #17 on: December 27, 2009, 03:27:50 PM »
I don't know why, but i feel you are more experienced in coding than you want us to believe :)


Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #18 on: December 27, 2009, 03:43:05 PM »
well, thats one thing i will not do.
it was painful enough to get windows running on this here old machine, rather loose an arm then re-deploy an OS. Supercomputers like this are not designed to do that :D

maybe one day, but for now i just stick to what i got.

hmm, endless loop sounds right, i set everything up right, but after a bit time my game page went berserk, and constantly updated.

Darn execution time limit.
Well, way around this is adding 1 single line.
Code: [Select]
set_time_limit(0);It allows a script to run for eternity.
Just what i need.

as for Chris, no way i would get some "creator" script.
What would be the fun in that?

You misunderstood what i try to do.
Revive my php skills, and make something on my own.
Don't you think downloading a source of something then modding it is not a true creation, just a modification?
No glory whitout pain.

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #19 on: December 27, 2009, 03:58:20 PM »
I don't know why, but i feel you are more experienced in coding than you want us to believe :)

Look, i read the tizag tutorials, and understood them. Also, if I need a function, i browse php.net manuals. The examples there help a lot. Also, Komodo has a nice feature of knowing all functions, and even gives syntax on how to use them. Rest is logics. Php is not rocket science. I'n not experienced, few years back i had done a "custom" solution at my work place to record stuff we have at hand, and it made nice PDF reports of sales, stock, what to order, yadada.. Not a big deal. Thats my PHP and mysql knowledge.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: My project: -yet unnamed game-
« Reply #20 on: December 27, 2009, 04:57:20 PM »
Yes, after reading it my post was unclear :)

What I meant is you should READ source codes of other games (not using the source code itself). Just studying it to check for the standard solutions to standard problems. For example thing like "infinite loop" does not exist in browser games, it is solved different ways and the most common one is cronjobs.

You went too quickly to implementing things in my opinion. One day spent on learning how others do these things would save you tons of hours in a long run.

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #21 on: December 27, 2009, 06:00:40 PM »
so-so.
But pseudo-crons are harder to manage in many aspects.
(the ones that calculate new data if user triggers something, like at page loads)

Endless loops are not used, thats true. Still its comfy for me to use it.
Ease of setup, and its a dirty-and-fast solution.
Just like my mysql injection filter.
Thats not a common solution, but still for now i think i leave it as it is.

When its all finished, end of a tick will be similar to when you log in to this forum, or post something. There is a page telling you to wait a bit, and it redirects you to your post.

It suits my needs good.
This solution has a bit of disadvantage as i see, as the server will have a lot to do if a tick is finished.
On the other hand, while users are redirected to the wait page, no further input is made.
So the server can do its job of data update, whit out the users interference.

I have a limited hardware here, limited knowledge and sight.
For nothing more but its at least an excuse for my poor quality of code.
If You review my "goal" it does not require superclean code and supernatural OOP and superior knowledge. Probably an experienced coder could do it in around 1-2 hours if not less.



Offline Xavier

  • Level 9
  • *
  • Posts: 52
  • Reputation: +1/-1
    • View Profile
Re: My project: -yet unnamed game-
« Reply #22 on: December 28, 2009, 03:58:02 AM »
It's always good to start with something small and not bother
with overanalysis. There's no better way to learn something
than practice. This is why my first game will be released as
soon as it is playable on the most basic level. Which will be
quite soon I must say.

And then one can build from that point up.

Start small, baby steps.

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: My project: -yet unnamed game-
« Reply #23 on: December 28, 2009, 06:31:46 AM »
heh, release for me.. Well, i will think about release when i have some content, lol.
Not too far from now, honestly. Bit of tweeking on the update stuff, then IF the first drade can be made with a dummy account i may make some. if you see me here online, then probably the "server" is running too. It means you can log in for a test run.
(So you can grab a ship, go to X buy some Y, go to Z, and sell it.)

as an essence its the raw backbone of the whole thing.
might add later more than 2 stations to trade with, and even more systems so people can go travel further to gain more profit. Some systems will have no PVP or PVE, some systems will have PVP.

But , before anyone is rushing ahed, total time i spend developing is equal to the time i'm online here.
So as for now its less than 6 hours.
I have to admit i done a decent job so up until now :D
Most people have major problems getting a game world to "move".
 

ST-Mike

  • Guest
Re: My project: -yet unnamed game-
« Reply #24 on: December 28, 2009, 11:31:21 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:52:39 PM by None »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal