PDA

View Full Version : Making my first PHP game!


GodsGal
10-04-2007, 01:49 PM
Alright, so I'm gonna be trying to make my first PHP game. I read up on the basics, and I have someone to help me out if I phail =P

For my first project I will attempt to duplicate the popular "higher/lower" strategy/chance game.

I'll probably use nutrinopets' version as an example because I have an account there and theirs is simple. Once I get a good copy working I'll change it up so it has my own little unique twist. :D

Once I start I'll be posting the code here for people to critique and analyze during the development steps!

I think this is a good project to start off with because it's simple enough that if I have trouble I can refer to a book or this forum, but it's complicated enough to make a fun, semi-dynamic game. :)

Opinions please? Maybe ideas on how I can make it unique.

GodsGal
10-04-2007, 04:47 PM
Alright, I know how to make the number random:

<?php
print rand(0, 25) ;
?>

But I don't know how to make the input buttons "higher" and "lower"

I know I have to make an If...Else... loop but I'm not sure how it works. I'm very new to PHP, so could someone help me out?

Sagashiteru
10-04-2007, 05:06 PM
Script analysis:

STEP 1
-choose a random number between 1-14(1...10, jack, queen, king, ace)
-create a form with 2 hidden fields(call one card and set it to your random number and call one action and set it to higher) and a submit button (http://www.w3schools.com/html/html_forms.asp) -> don't forget the method your using is post
- do the same for lower

if you need the second step then I'll explain that one too XD

GodsGal
10-04-2007, 05:27 PM
Thanks! I'll be sure to ask if I'm still confused.

EDIT: I read over it again and I'm confused. I understand the LOGIC to it but I don't know the first piece of CODE to write. :(

Roguos
10-05-2007, 01:38 PM
Alright, for the random part I usually use

$num1 = rand(1,10); instead of print rand(0, 25) ; then when your naming the forums in the name you'd put whatever you named the random number variable.

Hope that helped.

GodsGal
10-07-2007, 05:40 PM
Alright, I got it! Suteneko halped a TON so I can't take credit. He did the basic codes and I edited it to what I needed.

It doesn't do exactly what I was going to have it do but it's really close. ^^