Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Any fun PHP learning project

This thread is locked; no one can reply to it. rss feed Print
Any fun PHP learning project
Archon
Member #4,195
January 2004
avatar

I'm thinking of testing out LAMP and seeing whether it suits my webcoding-fu and also to learn how to efficiently use Apache, MySQL and PHP (probably version 5, why go with any earlier?). But I don't know what I should try and make.

Any ideas or constructive thoughts?

HoHo
Member #4,534
April 2004
avatar

Write a browser-based MMORPG ;D

Failing that, you can write some simpler game. I personally love Blacknova and I used to play LOTGD. Whenever I try to learn something new I always try to write some game, it has been like that with Basic, Pascal, C/C++ and Java. PL/SQL is the only language I've used more than just writing a few hello-worlds that I've not (yet) used to write a game.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Marco Radaelli
Member #3,028
December 2002
avatar

As HoHo said, games.

Another not-so-fun project could be a forum or a CMS :)

Archon
Member #4,195
January 2004
avatar

Is CMS, 'Content Management System', like a wiki? What could be the content?

Forums need a purpose to get people to participate.

Quote:

Write a browser-based MMORPG ;D

Well that would be interesting but the only things that I could think of are like Race-Wars Kingdoms (I think that it's called) and Arenascape.

Indeterminatus
Member #737
November 2000
avatar

A simpler thing to get started are multiplayer turn-based games. Take chess, for example.

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

Archon
Member #4,195
January 2004
avatar

Quote:

A simpler thing to get started are multiplayer turn-based games. Take chess, for example.

Would people mind playing over long periods like that (having turns that last 5 ~ 10 minutes long or longer)?

I'd kind of thought that something like chess on the web would be done using Java applets (like Jagex did).

Indeterminatus
Member #737
November 2000
avatar

Yeah, sure, that's also a possibility. I was thinking about the really lasting games that'd take weeks (with probably one move per day). The chess thread that was here on a.cc would be a perfect application for something like that.

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

Archon
Member #4,195
January 2004
avatar

Quote:

Yeah, sure, that's also a possibility. I was thinking about the really lasting games that'd take weeks (with probably one move per day). The chess thread that was here on a.cc would be a perfect application for something like that.

I guess that that could be a good idea, having multiple sessions and sign-ins. And other people can look at what the game is happening (plus a history of movements).

Anything else? :D

[edit]
PHP should be able to easily generate the boards and chess pieces?... What was used in the thread?

HoHo
Member #4,534
April 2004
avatar

Quote:

I'd kind of thought that something like chess on the web would be done using Java applets (like Jagex did).

Yes, it could but then you wouldn't learn anything about LAMP now would you :P

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

FMC
Member #4,431
March 2004
avatar

Quote:

PHP should be able to easily generate the boards and chess pieces?... What was used in the thread?

Yep, images where generated via a PHP script, check my sig :)

[edit]
Starting board:

r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R

You feed this to the link i have in my sig and the board is drawed

[edit2]
The code that shows the board, probably far from perfect but i never was a PHP guru and needed something that just worked, it may help you though :)

1<?php
2error_reporting(E_STRICT);
3//
4// ---- MAIN PROGRAM START ----
5// create image
6$y_off = 20;
7$x_off = 20;
8 
9if(isset($_GET["cset"])){
10 $cset = $_GET["cset"];
11 }
12 else {
13 exit();
14 }
15 
16if(file_exists("moves/".$cset) == FALSE)exit();
17 
18$set = file("moves/".$cset);
19$chess = array();
20$white = 0;
21$black = 0;
22for($x=0; $x<4; $x++){
23 $y = strrpos($set[$x], "*");
24 if($y){
25 $black = 1;
26 break;
27 }
28 }
29for($x=4; $x<sizeof($set); $x++){
30 $y = strrpos($set[$x], "*");
31 if($y){
32 $white = 1;
33 break;
34 }
35 }
36 
37for($x=0; $x<sizeof($set); $x++){
38 $set[$x] = str_replace("*", "", $set[$x]);
39 $set[$x] = str_replace("\n","", $set[$x]);
40 $set[$x] = str_replace("\r","", $set[$x]);
41 //$chess[] = array("P","P");
42 $chess[] = split(" ",$set[$x]);
43 }
44 
45$map["R"] = imagecreatefromgif("pieces/_T.GIF");
46$map["N"] = imagecreatefromgif("pieces/_N.GIF");
47$map["B"] = imagecreatefromgif("pieces/_B.GIF");
48$map["Q"] = imagecreatefromgif("pieces/_Q.GIF");
49$map["K"] = imagecreatefromgif("pieces/_K.GIF");
50$map["P"] = imagecreatefromgif("pieces/_P.GIF");
51 
52$map["r"] = imagecreatefromgif("pieces/T.GIF");
53$map["n"] = imagecreatefromgif("pieces/N.GIF");
54$map["b"] = imagecreatefromgif("pieces/B.GIF");
55$map["q"] = imagecreatefromgif("pieces/Q.GIF");
56$map["k"] = imagecreatefromgif("pieces/K.GIF");
57$map["p"] = imagecreatefromgif("pieces/P.GIF");
58
59if($white)$white_t = imagecreatefromgif("pieces/white.GIF");
60if($black)$black_t = imagecreatefromgif("pieces/black.GIF");
61 
62 
63$brd_n = "board_.GIF";
64 
65if(($white==0) && ($black==0))$brd_n = "board.GIF";
66$image = imagecreatefromgif($brd_n);
67 
68// allocate all required colors
69$colorBackgr = imageColorAllocate($image, 255, 0, 255);
70 
71$x = 0;
72$y = 0;
73foreach ($chess as $line){
74 foreach ($line as $ps){
75 if($ps != "."){
76 imagecopy ($image, $map[$ps], $x_off + $x*45, $y_off + $y*45, 0, 0,45,45);}
77 $x+=1;
78 }
79 $y+=1;
80 $x = 0;
81 }
82 
83if($white){
84 imagecopy ($image, $white_t, 0, 400, 0, 0,400,30);
85}
86if($black){
87 imagecopy ($image, $black_t, 0, 400, 0, 0,400,30);
88}
89// Date in the past, so that the image is not cached by the browser
90//Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
91header("Content-type: image/gif");
92 
93// now send the picture to the client (this outputs all image data directly)
94imageGIF($image);
95 
96imagedestroy($image);
97if($white)imagedestroy($white_t);
98if($black)imagedestroy($black_t);
99foreach ($map as $x)
100 imagedestroy($x);
101?>

[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites]
Written laws are like spiders' webs, and will, like them, only entangle and hold the poor and weak, while the rich and powerful will easily break through them. -Anacharsis
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. -Mark Twain

CGamesPlay
Member #2,559
July 2002
avatar

By the way, since you are just learning PHP, you'll want to adopt the best practices. You should do all of your development in strict mode, by calling this before anything else in your files:error_reporting(E_STRICT);

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

nonnus29
Member #2,606
August 2002
avatar

Quote:

Is CMS, 'Content Management System', like a wiki? What could be the content?

A cms is like what runs this site. Think of all the different parts: the depot, the forums, the picture of the day, the news, the member control panel, private message system, etc...

Make a simple cms: a front page with news and an image of the day that the user can update by adding new news items or images.

Thomas Fjellstrom
Member #476
June 2000
avatar

I have a suggestion, take a look at any popular PHP software, memorize exactly how they do anything and everything, and make sure never to do any of that, EVER.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Onewing
Member #6,152
August 2005
avatar

I'm wanting to incorporate php in some different aspects of my wip website (sortable tables, a news poster mechanism, simple game?, etc.). It's all new to me, so it's all fun really.

Here's an idea, if you are able to do cron jobs, have an AI entity move through a php world, where the periodic job just causes the next AI action to happen. From time to time, you can check to see what your entity is doing. It's like, "The Sims" php style. ;D

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Johan Halmén
Member #1,550
September 2001

Here's an idea I give away for free:

1. Create a game where you chase something in a maze. On the walls you see commercial companies' front web pages. If with clickable links, the better.

2. Make the game thrilling and addictive. Sell walls to these companies as advertising space.

3. Profit.

4. Remember me.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

nonnus29
Member #2,606
August 2002
avatar

Quote:

1. Create a game where you chase something in a maze. On the walls you see commercial companies' front web pages. If with clickable links, the better.

2. Make the game thrilling and addictive. Sell walls to these companies as advertising space.

3. Profit.

4. Remember me.

That makes about as much sense as selling a pixel for a dollar, and selling a million of them ala the 'million dollar web page'. It has to work..... :o

Archon
Member #4,195
January 2004
avatar

Quote:

1. Create a game where you chase something in a maze. On the walls you see commercial companies' front web pages. If with clickable links, the better.

2. Make the game thrilling and addictive. Sell walls to these companies as advertising space.

3. Profit.

4. Remember me.

That reminds me of an online Dark Reign 2 or Syndicate game that I thought of-thought of making (as in, just dreamed about), where there are billboards in high and noticable places and companies could pay to have a simple GIF playing on the billboards in the game. ;D

JonZ
Member #2,383
May 2002
avatar

I'd try and make a social networking site ;D Hear me out before you reply in a rage of fury :P. It will be good programming experience for the newcomer to PHP (it would help a lot if you are already well-versed in another language though). You'll get experience in creating proper DB schemas (think foreign keys, stored procedures, etc.). You'll also get experience in using JOINS and other fun-filled SQL related activities :P On the data model side you will get to do input-validation before saving to the DB. Incorporate AJAX along with the site for super-experience ;D

Another great idea that was mentioned was to create a CMS.

I'd suggest that you try to use the MVC model for any website.

Archon
Member #4,195
January 2004
avatar

Quote:

I'd suggest that you try to use the MVC model for any website.

Yes! I try to do that in my applications programming too.

Johan Halmén
Member #1,550
September 2001

My vague idea was in the first place that the user, while playing, actually visited the real pages of companies, but on these pages some animated character would move around.

I have no idea of how that would work. Is it possible to have some kind of layers in a browser, where one web page is shown on one layer and all links work? And on another layer some graphics would show, on top of the web pages. These graphics could have their own links, which could affect the bottom layer. This would probably need a special browser. And a PHP thing on a server.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Go to: