background preloader

30 game scripts you can write in PHP, Part 1: Creating 10 fundamental scripts

30 game scripts you can write in PHP, Part 1: Creating 10 fundamental scripts
Getting started As both a game master/storyteller and a developer, I frequently find myself writing little utilities and scripts to help me when running, planning, and playing games. Sometimes I need a quick idea. Other times, I just need a whole pile of names for Non-Player Characters (NPCs). Occasionally, I need to geek out on numbers, work out some odds, or integrate some word puzzles into a game. Many of these tasks become more manageable with a little bit of script work ahead of time. This article will explore 10 fundamental scripts that can be used in various types of games. We will blaze through these scripts pretty quickly. Back to top A basic die roller Many games and game systems need dice. In many cases, that would be more or less fine. Listing 1. function roll () { return mt_rand(1,6); } echo roll(); Then we can pass the type of die we want to roll as a parameter to the function. Listing 2. Random name generator Listing 3. Listing 4. Listing 5. Scenario generator Listing 6. Summary

HowStuffWorks "The Basics of C Programming" The previous discussion becomes a little clearer if you understand how memory addresses work in a computer's hardware. If you have not read it already, now would be a good time to read How Bits and Bytes Work to fully understand bits, bytes and words. All computers have memory, also known as RAM (random access memory). For example, your computer might have 16 or 32 or 64 megabytes of RAM installed right now. RAM holds the programs that your computer is currently running along with the data they are currently manipulating (their variables and data structures). float f; This statement says, "Declare a location named f that can hold one floating point value." While you think of the variable f, the computer thinks of a specific address in memory (for example, 248,440). f = 3.14; The compiler might translate that into, "Load the value 3.14 into memory location 248,440." There are, by the way, several interesting side effects to the way your computer treats memory. s:t 1:5 2:2 3:3 4:4 5:5 u = 5

Kevin William Pang 10. Comments explaining “what”, but not “why” Introductory-level programming courses teach students to comment early and often. Do you have any idea what the code above does? Me neither. The problem is that while there are plenty of comments describing what the code is doing, there are none describing why it’s doing it. Much better! Write comments to help readers understand the code, not the syntax. 9. In general, programmers tend to be more akin to locomotives than ferraris; it may take us awhile to get started, but once we hit our stride we can get an impressive amount of work done. 8. Wikipedia defines scope creep as “uncontrolled changes in a project’s scope”. Version 1: Show a map of the locationVersion 2: Show a 3D map of the locationVersion 3: Show a 3D map of the location that the user can fly through 7. Management is not an easy job. 6. It’s not hard to see that this is something programmers dread doing. 5. I never said that we weren’t hypocrites. 4. 3. “The website is broken”.

25 New Script Libraries and Plugins on GitHub Git is a powerful, open-source distributed version control system and social code repository. GitHub is the world's largest open-source community, hosting millions of public repositories. Users add innovative new projects on a daily basis. With the latest new Repos available to fork and explore, it can be difficult to stay updated. Please note some of the GitHub resources reviewed may be slightly older in origin, but they have been recently updated, much improved upon or generally overlooked as resources really worth exploring. Have you discovered any GitHub script libraries or plugins we may have missed? 1. Unveil.js is a lightweight version of LazyLoad, with support for serving high-resolution images to devices with Retina display. 2 Chardin.js Chardin.js (named after the French painter Jean-Baptiste-Siméon Chardin) lets you add simple overlay instructions on existing elements, on any of your apps, using JavaScript. 3. 4. 5. 6. 7. 8. 9. 10 . 11 . 12 . 13. 14. 15. 16. 17. 18. fpsmeter.js

Related: