|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
New-b needs help on PHP...(roll your eyes)
Well, it goes like this...
I've decided that I want to create a mmog (massively multiplayer online game). This will require php. (I know there are other options, but after looking around a bit, php seems the best and easiest.) The problem is this...I don't know php. So after outlining what I wanted the game to do, which I may cut down on to start off with since I don't know php, I decided to run around and learn as much as I could about general php and it's functions. Now, I've been reading up on php for most of the day. While I have a much better understanding of basic principles involved with php, I still don't know the first steps I need to take in creating a php document. I know that this depends on what the documents purpose is, what other documents it will call upon, and what other documents will call upon it. But lets start out simple. 1) A user wants to buy a piece of candy priced at 2 tokens. The user has 4 tokens. How do I get the users 4 tokens to subtract 2 tokens from it when they purchase the candy via a "purchase" button? 2) Every 15 minutes, a user recieves 5 tokens to their "purse". They don't have to be logged in for this to happen. The purse is in the users profile page. How do I get the 5 tokens to generate in the users "purse" every 15 minutes? -thanks, stumps -----ingnore this part unless interested----- Also...I do want to write this mostly by myself, but if anyone is curious and has the time I don't think I'd mind the extra hand with this project as I've got about 5 other projects going on at the same time. |
|
#2
|
||||
|
||||
|
Are you sure PHP's gonna do the trick? When I think MMOG, I think cutting-edge graphics, animation, near-real-time, non-request-based client-server communications, etc. Of course, I'm not a gamer, so I may have the wrong idea here. If I am on the right track, I think you're probably on the wrong track. PHP (and most standard Web languages) are transaction-based. That is, you go to a page, fiddle around with some form blanks, submit your information, and wait for the response. It's linear rather than the 3D many-things-happening-at-once world that I imagine those interested in MMOGs would demand.
That said, you'd do best to develop an application framework rather than approaching this piecemeal. It sounds complex enough to merit that, at least. If you go piecemeal, you'll wind up with all kinds of meaningless code that works but is impossible to decipher and maintain. Obviously, you'll need a database to store all the information passing back and forth, and with the 15-minute deal, it sounds like you'll need cron access (though that could be gotten around so long as you track last login time). I'll give you some sample pseudocode in answer to your first specific query: - Instantiate user object, pulling vars from the db. - Get the amount value from the purse variable/object associated with the user. - Subtract the token value of the candy from the purse value - If greater than or equal to zero, update the purse value in the db and print a success message. Also update the db to reflect the amount of candy the person has. - Else print a message saying that the user doesn't have enough money. You can see how having code like this for every single little transaction that takes place within the game could result in a rat's nest of code. So an application framework, or at least an object hierarchy, is going to be very helpful as far as making your code maintainable and portable.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
||||
|
||||
|
no, no...I gave you the wrong idea I'm afraid.
I should have said browser based mmorg. There is a version of mmorg's out there that are strictly text and picture based. No 3d realm or real-time stuff going on. A good example of this is www.kingsofchaos.com In these games you do fill out blank forms or select given choices from the forms. You attack by choosing another user from a list. These lists usually also list something like the power rating and some other ralevent stats. In some more advanced versions of these games, you then choose what type of attack and how many units to attack with. Some of them also have interactive maps in them that allow for you to select different areas to get info on that area, which might or might not be owned by another player. These map versions are very rare, and tend not to be pursued because of the limitations that it puts on the games univers. This is the type of game that I'm looking to make. So far as I've researched (view source, and reading the about sections) these games are primarily made using php. |
|
#4
|
||||
|
||||
|
As for the response to the coding question...
I understand what you are saying with the listing that you've given, but I don't really know how the code is technically supposed to look for it. I'm not asking you to write the code in which I will copy and paste...what I'm looking for is basically a better understanding of what the code looks like for the things that I want to do. Really, I'm quite lost, because unlike HTML I can't really just go grab someones source code and start picking it apart and preview the changed that I've done. That's how I learned html. It's the way that I learn best, but picking apart code and messing with it to see what it does. With php however, it's not really fesable(sp) to do that because of how it ties together with other documents. I'm not sure how I'm going to learn how to do everything that I want to do, or even what it is that I need to know in php that I need to accomplish my goal, but I do know that I'll try my damnedist to do it. If this will help, here's the basic outline that I've put together. It has the basic draft of what the game needs to be able to do. There are two documents: Outline, and Battle. Battle is a brief overview of attacking as defense is covered in the outline. Read the outline first. Also, just choose to open the file rather than saving it...it's easier. [deleted]sorry, can't leave them up forever. Security issues could be an issue with the content.[/deleted] |
|
#5
|
||||
|
||||
|
Right, I knew what you were after -- I just wasn't sure it was the sort of thing others would find appealing, given all the other interactive games out there. Clearly there is a demand for such games, given your additional comments.
As for how to code something like this, it really stands to be a pretty complex piece of code, and my comments stand. You should cut your teeth on a smaller project that'll allow you to pick up some of the basic principles you're missing. Then you'll be in a better position to figure out how to put together a larger site like this. You'll find the function reference at php.net very handy, and you might want to pick up a book that'll introduce you to the basics. And then there's good database design to get under your belt. This is too much to cover in a forum. It's a whole training course. Start by digging up PHP and mysql tutorials, and try to write something pretty small for starters (a little contact database, for example, which you can later roll into your game as the user database) that forces you to learn database calls and basic PHP logic. Once you've got that under your belt, the rest is really just a matter of being able to find the right combination of functions to solve whatever problems you face. |
|
#6
|
|||
|
|||
|
Coding.
As i have been on making a game like that my self, browserbased. I can give you some genneral idear of the coding. It is af follows:
The substraction of the 2 tokens from the client purse: 1. U need to have the client make a user. This user, is then in the db, given a unique id-number (name the first collum in the db "id" and make it primary, and auto_increase.) 2. this id, is then used to define what ourse belongs to who. 3. Make a collum named ei. purse, and put in there by default ei. 10 token. then when ever the user byes something, UPDATE the db where id is userid, by the new amount (the new amount is calculated by the current site. by getting the "purse" amount from the bd, then substracting 2 token, then updating the db again) 1.) PHP Code:
2,3. ) setting a cockie on the client computer, is a nicxe thing, but otherwise, indentify USERID by login name and pass, and then read the ID from the db where this coinsides. And fore the 15 token a hour, i believe, that a timestamt or time-date in the end of each user, and the having a connection with the internal serverclock, can make fore an update function. But im not sure of this. But ill look into it sometime tomorrow. - Pheifel |
|
#7
|
|||
|
|||
|
Not to be cynical, or obnoxious, or completely unhelpful. Isn't this similar to a permit-toting driver applying to nascar? But seriously, as an intermediate PHP coder, I have come across this idea on numerous occasion. And honestly, you have to think beyond game concept. You may have an incredible idea. But to make a game worth playing is going to take a little more then some basic language knowledge. I would suggest learning PHP more in depth, then see if the idea is still feesable.
|
|
#8
|
||||
|
||||
|
Thanks Pheifel,
that's what I was looking for. Now I can go looking for this on the net. Dhouston, Yeah I know. That's what I'm probably going to end up doing. I just want to find out what basic types of functions are the core ones that I need to keep an eye out for while I'm putting together the smaller versions. That way, I can I'm not studying needless functions hoping to find the one that I need. What Pheifel put up will suffice for now. Thanks for the referance to php.net. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > New-b needs help on PHP...(roll your eyes) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|