Tag Info

Hot answers tagged

34

*Edit: Fixed error in javascript that caused error on firefox * Edit: just added ability to scale hexes to the PHP source code. Tiny 1/2 sized ones or 2x jumbo, it's all up to you :) I wasn't quite sure how to put this all into writing, but found it was easier to just write the code for a full live example. The page (link and source below) dynamically ...


18

What you implemented isn't Perlin noise. I'm not sure why Hugo Elias says it is, but he's confused. Here is Ken Perlin's reference implementation. It doesn't actually call any external random number generator, but uses a built-in hash function to produce the pseudorandom gradient vectors. Note also that Perlin noise consists of just one octave. Summing ...


17

Don't trust the client. It's as simple as that. Any safeguard you can put in place can be broken; and truly safe methods are impossible within the scope of JavaScript. The best approach is to only trust the client with drawing what you send it and retrieving user input. Giving it anything more is just asking for trouble. Any information you send to your ...


13

Two suggestions: Exponents! Calculate some "base xp reward" for each level. Then the formula for a kill is base_xp_reward * pow(1.1, target_level - player_level). You might want to clamp the gain to a maximum, to somewhat nullify exploits, and you might want to give zero XP below a certain difference, to prevent farming of lowbies. (Base XP reward can be a ...


11

You should write a small javascript tile layout engine that maps the database tile coordinates into a view on the web page, because this lets you outsource the cpu processing time to the players computer. It's not hard to do and you can do it in few pages of code. So essentially you'll be writing a thin layer of PHP of which only purpose is to deliver ...


10

PHP is still relevant for browser games. There are tons of companies (Gameforge, Funzio, Goodgame Studios, etc.) that use PHP for their online games. I think PHP and Java are most widely used, but learning something like Node.js and Python can be beneficial as well. It really depends on what you want to focus on. Learn new technologies/a new programming ...


9

You could build the entire game in JavaScript for sure. Be aware that the source-code will be visible to the user. So if you're concerned about cheating (probably a non-issue if it's just a single-player game), then you should have your game logic on the server. JavaScript and PHP is definitely going to work. If I were creating such a game, I would do the ...


8

First of all, don't skimp so much on space. Even on shared hosting you'll get several GB of space and if you're not storing large binaries or entire books or something, CPU and memory are going to be bottlenecks before disk space is (usually). I thinking keeping int columns as small as possible is pretty old advice when disk space was more expensive than ...


8

That's a common misconception. What Hugo Elias calls "Perlin" noise is in fact fractal, or pink, noise. To better understand what Perlin noise is, you can read Perlin's article linked in Nathan Reed's answer, or libnoise docs (there's the same error there: Perlin noise is what they call Gradient noise), or CoherentNoise docs. Now, to actually answer your ...


8

For a real-time game, you want to minimize latency. Here's two tips for achieving it, with notes about PHP and Node: Use WebSockets. They allow fast two-way communication between the server and the client. Using node.js here has the advantage that you can use the same JavaScript API on both ends of the pipe. There's also the wonderful socket.io module for ...


7

However, the amount of content could be potentially very high, and it may be too hard on the server's resources once the game grows bigger - userbase included. The other way to do it to simply hardcode everything in: What makes you think that a system can cope with it in hardcoded form, but not when it's stored in a database? Databases are designed to ...


6

I would write the server in the language/toolchain you know best, rather than learn a new one for that purpose, especially if you have any concerns about making the server "watertight." You're more likely to make mistakes with technology you are unfamiliar with. Unless the cost is prohibitively more to run a Windows server, I would stick with that platform. ...


6

Ok, currently there's 4 major options for browser based games. Java - Revived mostly due to Minecraft and Android, Java requires a plugin with about 75% market penetration (source). It's also a fairly complicated language that really isn't suited for first time programmers. There's advantages to using it, but it's probably not the best option. Unity - ...


6

I first thought I would simply put it in the (MySQL) database Sounds good! but I think it will be too much. Then you don't know the limits yet. Seriously, just throw everything in a database. Don't care about performance too much at this stage, if it becomes an issue you can fix it later. Here's an abstract view of what your database could look ...


6

Several points: You should definitely enable error reporting and error logging into a file on the PHP side, otherwise you'll have no evidence of problems. AJAX errors usually cause little visible error to the user. You should check for errors on the Javascript side too PHP error handling is famous for being both bad (e.g. the default action for most ...


5

about knowing other players' data: The only real way to prevent the client from knowing something, is not telling it to him. *ANY* other kind of doing it will be breakable with a variable amount of effort, depending on how strong your system is. about user's own data: Anything you need to store, you need to store it on the server: anything that comes ...


5

As to but what would the method be when the player logged in and you needed to get their inventory etc You need to look at Managing Sessions and State with PHP or PHP Session Management With Cookies. In general when the player logs in you'll query the database for all the information needed to hydrate the objects associated with the player, such as ...


5

I've recently used both models A and B in two different games. Neptune's Pride and Jupiter Folly. In both games, when two armies meet, they fight until one army remains. In Neptune's Pride, players take turns inflicting damage on one another until one of the armies is dead. In Jupiter's Folly, the strength of the armies is simply compared and some die ...


5

1) giving JS end-users direct access to your terminal is the scariest idea ever, in terms of security, and is 100% impossible without some interfacing server language/framework (php/perl/ruby/c#/python/java/c++/NodeJS), because it is so scary. 2) running exec() on user-input, directly, rather than building an interface in your server language is 100% as ...


4

What you're doing here is premature optimization. Modern RDBMS can handle much more records and are optimized for speed and efficiency. There's no point in simplifying your DB-design like that, because: You'll loose flexibility. You will have to do the stuff in your code that was previously handled by the RDBMS (eg. get all inventory items as separate ...


4

PHP is still relevant and widely used. According to the TIOBE Programming Community PHP is the fifth most popular language. It was in fourth position last year. That decrease could simply be due to an increase in the amount of available technologies. I'm assuming there is some correlation between general programming language popularity and game programming ...


4

You're probably going to have to break down what kind of rules you guys have created in the past and just let the computer pick one at random and fill in the specific details. As far as your high level goals this isn't going to make it really "funny" since you'll know all the possible outcomes, but it will make the game possible. So for example, the "lay a ...


4

Better? Probably, but at what cost? PHP has a truly fully-featured string API which will come in handy as soon as you do just about anything with text. C# has native code and some added speed at the cost of having to use an awful API and the JIT compilation on first launch makes testing painful. Python has a rather uncomfortable reference system so copying ...


4

Although I'm not PHP fan, I don't think it's a problem of the language, 300,000 rows in a database is not that big (I worked with much more). Your problem is most likly in the code-> algorithms you use.. As a side note.. 1000 lines of code for just fight logic? How maintainable is that? It's ok that you know what's going on in there right now, but will ...


4

As the others already mentioned....300k of rows from a database and 1k lines of code shouldn't really be that huge of a problem for the memory. Although if you load all 300k rows into memory at once (depending on how much data is in each row) that COULD pose a problem. Another possibility would be memory leaks especially as the phenomenon that you write ...


4

I recently created a test program for an algorithm I found. It works on the premise of: I'm an evil overlord and I want more space. Basically the room is seems to be built out of necessity rather than uniformly with corridors. The stages are as follows. Fill the whole map with solid earth Dig out a single room in the centre of the map Pick a wall ...


4

I know your question is specifically asking about cron jobs, but I think a lot of web-based mmos are written using "completeTime" logic as opposed to lots of crons. When you start a long-running action, like building a granary that takes 5 hours to complete. The server will just mark the granary's completion time as start time + 5 hours and store that in ...


4

There is one thing that bothered me about your question: "..But the only programming language I know is Java." So learn another one! Anyway, Java as a client in the browser fails on many, many fronts. For one, Java 7 (and most likely Java 8) doesn't even work in Chrome on Mac OS X because the Java people decided to stop supporting 32-bit, and Chrome ...


3

I just stumbled on this the other day -- check out NowJS at http://nowjs.com/ as I think it will give you a nice solution. From the site... NowJS creates a magic namespace "now", accessible by server and client. Functions and variables added to now are automatically synced, in real-time. Call client functions from the server and server ...



Only top voted, non community-wiki answers of a minimum length are eligible