Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×

Submission + - Book Review: Core HTML5 2D Game Programming (corehtml5games.com)

eldavojohn writes: Core HTML5 2D Game Programming details a journey through creating Snail Bait in well defined steps. This simple two dimensional platform game works as a great starting point for anyone interested in making their very first game targeting many desktop and mobile platforms. This incremental process is expertly segmented into logical lessons with the only prerequisite being fluency in JavaScript. One of the most attractive aspects of this book is that the core concepts of this book don’t rely on some flavor of the week JavaScript library or framework.

author David Geary
pages 615 pages
publisher Prentice Hall
rating 9/10
reviewer eldavojohn
ISBN 9780133564242
summary An exercise in 2D game development and mechanics in HTML5 and JavaScript.

First, this book isn't for people who do not recognize HTML5 and JavaScript as a valid development platform for games. I know you’re out there, you can stop reading here and move on to the next article. This book isn't for you. If you have no programming experience this book is likely not for you either. This book dives into concepts faster than Geary’s last book on game development in Canvas. You should also be familiar with JavaScript if you want to effortlessly start on this book. Throughout the book, Geary utilizes object’s JavaScript prototypes to add functions, uses anonymous functions and refers to common programming patterns.

It is worth repeating that the implementation in this book does not rely on a framework or library that could change or go defunct. The game runs entirely on code covered in the book accessing W3C standard specifications like requestAnimationFrame(). As long as JavaScript interpreters don’t change core things like timing control, this book should be relevant to developers for years to come.

The reason this book gets a nine is it accomplishes everything it sets out to do and Geary does a great job dividing up task after incremental task of setting sprite sheets and backgrounds into motion. The reason it doesn't get a ten is that I was personally disappointed with the the author devoting little time to physics and their simulations.

The book is laid out to enable its use as two kinds of resources: cover to cover and chapter specific topics. Reading this straight through, there were only a few times where it felt like I was needlessly being reminded of where I had already read about tangential topics. On the plus side if you ever want to see how Snail Bait implemented something like sound, you need only spend time on the chapter devoted to sound sprites. One mild annoyance I had with the text was that the author seems to always refer to Snail Bait as “Snail Bait” which leads to a Ralph Wiggum-like aversion to pronouns or saying “the game” instead occasionally. It might only be me but it can become tiresome to read “Snail Bait” five or six times on the same page.

You can read a sample chapter here that shows how to implement sprite behaviors.

The first two chapters of the book focus on a set of basic guidelines to follow when doing game development in HTML5 and JavaScript — like keeping certain UI display elements in CSS instead of rendering them as paths or objects in the Canvas. Geary also covers the very absolute simplest concepts of how graphics are going to be displayed and how the background is going to move. He also spends time in Chapter Two showing how to best set up the development environment. It is demonstrated how shortening your cycle of deployment saves you tons of time and the author does a great job on letting you know what tools to use to debug throughout the whole text.

The third chapter delves into draw and rendering graphics in the canvas as well as introducing the reader to the game loop. It spends a good amount of time explaining the use of animation frame control in a browser to keep animations running smoothly. It also begins the auditing of frame rates so that the game can respond to and display things normalized at the rate the user is experiencing them. It also touches on how parallax can be employed to show things closer up moving faster than those further back in the background. This illusion of depth has long been popular and is even finding its way into scrolling on blogs and I wish that Geary would have spent more time on this perhaps in a later chapter but offer the reader more on how to do multiple levels of depth.

The next chapter tackles the core infrastructure of Snail Bait and discusses at length encapsulation of certain functionalities (instead of globals) in the source code as well as Snail Bait’s 2300 line prototype. It bothers me that one file is 2300 lines and I wish there was a better way to do this but as a learning tool, it works even if it is daunting to scroll through. The book adds some helpful pointers about how utterly confusing the “this” keyword can be in JavaScript. Chapter Four really sets the pace for the rest of the book by introducing the use of event listeners and illustrating how the game loop is going to continually be extrapolated.

The next three chapters cover the use of loading screens, sprites and their behaviors. Snail Bait uses all its graphics from an open source game (Replica Island). But if you were to design your own graphics for your game, these chapters do a great job of showing how to construct sprite sheets and how to use tools to construct metadata in the code so that the sprites are usable by the sprite artists. Using the flyweight pattern, Geary sets the stage for more complex behaviors and actions to come in the following chapters.

The next three chapters cover time, stopwatches and their effects on motions and behaviors within the game. The author starts and works from linear motion to non-linear motion and then using transducer functions to affect the time system. The game now has bouncing coins, a jumping player and Geary does a good job of showing the reader how to emulate behaviors in the code.

Naturally what follows next is collision detection and gravity. The collision detection strategies were adequate but I wish that there was more depth at least referenced in the text. This isn't a simple problem and I did like how Geary referenced back to chapter two’s profile and showed how collision detection performance as you implement and refine and optimize your algorithm. The nice thing about this book is that it often tackles problems with a general solution in the code (runner/sprite collision) and then provides the edge case solutions.

In the fourteenth chapter, the author tackles something that has long been a plague in HTML5 games: sound and music. The author doesn't sugarcoat this citing the long history of problems the vendors have had trying to support this in browsers. There’s a great explanation of how to create and handle “sound sprites” (similar to sprite sheets) so that there is only one download for background music and one download for audio sprites.

Next Geary covers the problem of multiple viewport sizes with a focus on mobile devices. Of course this is one of the biggest issues with mobile gaming today. The chapter is lengthy and deals with the many intricacies of scaling, sizing and touch events. This chapter is long but the highly detailed support of multiple platforms and resolutions is a justified discussion point.

In sixteen, the reader gets a treatment of utilizing sprites and their artists to simulate sparks and smoking holes. The book calls this chapter “particle systems” but I don’t think that’s a very good title as the code isn't actually dealing with things at the particle level. Instead this chapter focuses on using sprites to simulate those behaviors via animation. This is completely necessary on a computation inexpensive platform but it is misleading to call these particle systems.

Now that the game looks and functions appropriately, the book covers UI elements like player scores and player lives. The auditing of these metrics are covered in the code as well as warnings when the game begins to run to slowly. It also covers the ‘edge’ condition of winning in the game and the routine that is followed when the user wins the game.

The next chapter introduces the concept of a developer backdoor so that the reader can manually speed up or slow down the game while playing it or even test special cases of the runner sprite interacting with other elements. It’s a useful trick for debugging and playing around but does devote a lot of time to the specialized UI like the speed slider and other things that won’t (or rather shouldn't) be seen by a common player.

Chapter nineteen really felt out of place and very inadequate on important details. It’s a blind rush through using node.js and socket.io to implement server side high scores. The way it’s implemented would make it trivial for someone to submit a high score of MAX_INT or whatever to the server. The metrics reporting is done in a manner that (in my opinion) breaks from long established logging structure one would be familiar with. While it covers important things to record from your users in order to tweak your game, the inadequacy of discussions about shortcomings makes it feel out of place in this text. It's a topic of great depth and I have no problem with an author touching on something briefly in one chapter — this chapter does lack the warnings and caveats found in other chapters though.

Contrary to the previous chapter, the final chapter is a fast application of the entire book’s principles applied to a new game (Bodega’s Revenge). Geary gives a final run through showing how the lengthy prior discussions quickly translate to a new set of sprite sheets and game rules. If this book is ever expanded, I think it would be great to include additional chapters like this although I would pick a more distinct and popular two dimensional game format like a tower defense game or a bejeweled knockoff.

Overall, Core HTML5 2D Game Programming is a great book for a JavaScript developer looking to dabble in game development. You can purchase Core HTML5 2D Game Programming from barnesandnoble.com. Slashdot welcomes readers' book reviews (sci-fi included) — to see your own review here, read the book review guidelines, then visit the submission page. If you'd like to see what books we have available from our review library please let us know.

Comment No. (Score 5, Insightful) 228

To be fair to Zuckerberg and Facebook, the company must obey the law of any country in which it operates.

No. He came out in support of a universal maxim and then went back to his board who showed him X dollars of income they get by operating in Turkey. Just like the revenue lost when Google left mainland China. Instead of sacrificing that revenue to some other social network in Turkey run by cowards, he became a coward himself in the name of money. It is an affront to the deaths and memory of the Charlie Hebdo editors. His refusal could have worked as leverage for social change in Turkey but now it will not.

So no, your statement isn't fair to Zuckerberg and his company and the platinum backscratcher he gets to keep with "TURKEY" inscribed on it. Fuck that greedy bastard and his petty meaningless lip service.

Submission + - Valve's Economist Yanis Varoufakis Appointed Greece's Finance Minister (ibtimes.co.in)

eldavojohn writes: A turnover in the Greek government resulted from recent snap elections placing SYRIZA (Coalition of the Radical Left) in power — just shy of an outright majority by two seats. Atheist and youngest Prime Minister in Greek history since 1865 Alexis Tsipras has been appointed the new prime minister and begun taking immediate drastic steps against the recent austerity laws put in place by prior administrations. One such step has been to appoint Valve's economist Yanis Varoufakis to position of Finance Minister of Greece. For the past three years Varoufakis has been working at Steam to analyze and improve the Steam Market but now has the opportunity to improve one of the most troubled economies in the world.

Comment Rumor: Fox Is Planning an X-Files Revival (Score 1) 480

In the news recently are rumors that Carter, Anderson and Duchovny will reunite for new X-Files episodes. Fox has sorta confirmed this.

I own all the DVDs, a couple years ago I rewatched them. I may come off as a rabid fan at times but the background music was atrociously horrid. Also the story arc plot became overly convoluted and impossible to explain at times. That said, one of the most convoluted characters (Krycek) was my favorite. Aside from several minor valid criticisms like that, I really think it's a great platform for modern storytelling.

I do have to ask myself, at times, if there is some level of insane conspiracy theory today that we owe at least in part to those people watching X-Files when younger. I have to admit that the 9/11 inside job truthers movement claims could have been ripped from the pages of an X-Files script.

My biggest concern, of course, is whether or not it could still be fresh. With recent high quality additions to television canon, we'd have to be prepared for Chris Carter coming back at us with a 90's angle when episodes like Home really aren't as shocking anymore. The bar has been raised (thankfully).

Right now, The X-Files is going to occupy a contextual place in television history like The Twilight Zone. A revival could very well tarnish that. On the other hand, I've never felt like I really received closure on the whole story arc ...

Submission + - Seismological Society of America Claims Fracking Reactivated Ohio Fault (seismosoc.org) 1

eldavojohn writes: There have been suspicions that fracking has caused minor earthquakes in Ohio but last year seismic data recorded by the Earthscope Transportable Array was analyzed by the Seismological Society of America using template matching and has resulted in a new publication and press release making the statement that Hilcorp Energy's fracking in Poland Township in March of 2014 "did not create a new fault, rather it activated one that we didn’t know about prior to the seismic activity." The earthquakes occurred in the Precambrian basement and lead the researchers to posit that further unknown faults may be activated by fracking. The press release ends with urging for "close cooperation among government, industry and the scientific community as hydraulic fracturing operations expand in areas where there’s the potential for unknown pre-existing faults."

Comment Early Soviet Computing? (Score 4, Interesting) 80

Alexander Stepanov, I have never had a chance to ask someone as qualified as you about this topic. I grew up on the opposite side of the Iron Curtain and have constantly wondered if (surely there must have been) alternative computing solutions developed in the USSR prior to Elbrus and SPARC. So my question is whether or not you know of any hardware or instruction set alternatives that died on the vine or were never mass fabricated in Soviet times? I don't expect to you to reveal some super advanced or future predicting instruction set but it has always disturbed me that these things aren't documented somewhere -- as you likely know failures can provide more fruit than successes. Failing that, could you offer us any tails of early computing that only seem to run in Russian circles?

If you can suggest references (preferably in English) I would be most appreciative. I know of only one book and it seems to be a singular point of view.

Comment Are You Joking? (Score 3, Interesting) 182

> It is not known how the US government has determined that North Korea is the culprit

Of course it's known. The same way they established that Iraq had chemical weapons. The method is known as "because we say so".

Are you joking? I thought it was well established that there were chemical weapons in Iraq we just only found weapons designed by us, built by Europeans in factories in Iraq. And therefore the US didn't trumpet their achievements. In the case of Iraqi chemical weapons, the US established that Iraq had chemical weapons not because they said so but because Western countries had all the receipts.

Comment Is Bloomberg the New Buzzfeed? (Score 5, Informative) 461

What the hell is up with the title of this article? Nowhere did I find any indication of anyone being "scared" or "frightened." On the contrary the article presents contradicting information:

Still, the Edison Electric Institute, a trade group representing America’s investor-owned utilities, recently announced that its members will help to encourage electric vehicle use by spending $50 million annually to buy plug-in service trucks and invest in car-charging technology. “Advancing plug-in electric vehicles and technologies is an industry priority,” said EEI President Thomas Kuhn.

Uh, "advancing as a priority" is actually the opposite of fear.

Southern California Edison is planning to spend about $9.2 billion through 2017 to allow the two-way flow of electricity on its system, said Edison International CEO Ted Craver. “We are certainly big supporters of electric transportation,” Craver said. He added: “That electric car isn’t just going to stay at home. It’s going to go other places. It’s going to need to get charged in other places. And I think our ability to provide that glue for all those things that are going to plug into that network is really how we see our core business.”

Again, sounds positive. Actually the only negative thing in the article is that electric cars might cause a load our infrastructure isn't ready for -- to the contrary a solar charging station in the home would mitigate this. Is the new journalism format to title your articles with a thesis directly contrary to all the actual evidence you're about to present?

Comment Re:we ARE different (Score 1) 355

Higher IQs are correlated with a long history of urbanization and economic specialization, where higher IQs provide a selective advantage.

There's no arguing this. But, from what I've read about James Watson, he never said anything close to this. Instead, I can even find on his wikipedia page this quote from one of his books:

He writes that "there is no firm reason to anticipate that the intellectual capacities of peoples geographically separated in their evolution should prove to have evolved identically. Our wanting to reserve equal powers of reason as some universal heritage of humanity will not be enough to make it so"

So it's related to a long history of urbanization and economic specialization? And also Watson's unequal powers of reason? What is he implying if not to say that genetically some people are born without the equal "powers of reason"? He didn't quite say that due to "a long history of urbanization and economic specialization" instead he said due to geographic separation followed by their evolution. Watson's position as a genetic researcher commenting on something that is almost certainly attributed to socioeconomic status is strange, wouldn't you think? Was he commenting on this as an economist or perhaps historian?

I also like how you link to wikipedia pages but not their internal discrepancies on your open and close case that IQ is inherited. Including this quote from your first link:

Eric Turkheimer and colleagues (2003) found that for children of low socioeconomic status heritability of IQ falls almost to zero.

From this source.

You present a perfectly acceptable and fairly logical argument about the advancement of some cultures outpacing others. One need only read "Guns, Germs & Steel" where this sort of thing is discussed in a very sound and well researched way. Do we raise our pitchforks and chase after Jared Diamond with fervor? Not at all. Then again, his arguments didn't rest entirely upon some imaginary gene expression he just hadn't found yet.

Your "political correctness" claim is largely rubbish. While it may appear a knee-jerk reaction, this is the case of people objecting to a statement with no underlying scientific basis while Watson makes claims that we should be able to isolate the "Intelligence Gene." Have we had success in isolating such a gene from the Ashkanazi? Furthermore Watson implies (though never directly says) that lack of similar genes is what keeps Africa repressed -- while making zero reference to the reverberating effects of hundreds of years of European colonizations and their leeching of wealth & resources.

Comment Of Course It Was (Score 3, Insightful) 355

Your comment is extremely racist.

You're goddamn straight it is. The point is that any population -- no matter how high and lofty it is can be the target of stupid shit attributed to their genetic structure with "just so" fallacies. He makes inflammatory statements, doesn't even offer correlation as evidence for them and completely ignores socioeconomic conditions of even the past two hundred years.

How hard is it to turn James Watson's high minded lofty DNA superiority complex against his home city? Not hard at all, it turns out. Simply cherry pick from painfully recent history the horrible stereotypes and wars that their ancestors have and totally ignore any outside forces like ... oh, I don't know, the slave trade ... and then just "painfully" wish you were wrong. Notice how I apologized for having to be the one to first acknowledge something I'm not proving.

What blows my mind is that Africa was for tens of thousands of years in the same state that the rest of the world was in -- hell it's the birthplace of homo sapiens. And the time scale we need to talk about for DNA to change is at the very least tens of thousands of years. 25 million years of human evolution and James Watson measures 'genetic skin-color-intelligence correlation' from his apparently very short knowledge of history. Let's be generous and say he actually considered the past two thousand years which would be odd that he chose not to acknowledge that Europe's age of colonialism had something to do with Africa's current state.

Just like my post listed zero gene expressions, I'm not aware of any he's presented backing his statements. Furthermore, how would one divorce the nature versus nurture in such a test? The long history of racial discrimination the world over would need to be carefully controlled out of the experiment and the fact of the matter is that you can't. I'm not a Nobel prize winning geneticist and even I recognize this.

Comment Chicago, Illinois: The Real Problem (Score 5, Insightful) 355

Do you ever notice how enamored with American football the Chicago population is? How much money they dump into the Chicago Bears? Oh, how I wish that I would be wrong but often science is meant to be inflammatory. The testing simply shows that the people of Chicago are slovenly drunks who cannot help but repose in sloth upon their reclining chairs in their own pitiful squalor. How can we help the people of Chicago when all of our policies revolve around thinking of them as good decent hardworking people?

About a third of the Chicago population is German. Genetically, therefore they have instilled in them a 'Crazy Fourth Reich Fever' that millennia of conditioning by the BLACK Forest of Germany and they simply only want to fight and invade other peaceful peoples that are doing nothing but contributing to the advancement of the human race. Alas, my mind is tortured that nature could be so cruel as to instill a fine specimen like the German with such brutal and total warring instinct. But we simply cannot be able to even begin to help Chicago out of shit-hole status unless we come to terms with their genetically corrupted DNA structure. I know this may seem shocking to you lay people but I have suffered as Galileo has suffered. Science requires I tell you the truth that I seem to have no scientific basis for yet I know deep down in the pit of my Swedish-American stomach to be true.

Another third of the Chicago population is Irish. Genetically the Irish have evolved in an inherently beautiful land that has caused them to drink heavily whenever outside of this land. This is to deal with the squalid landscapes of Chicago. Blame them not, they are only following the unavoidable bonds of nature that tie into their DNA and make them wholesale worthless drunks. There is no hope for them and, verily, we cannot hope to even get them into rehab until we understand that there simply is no rehabilitation for them. Their origin country has a short pitiful record that I can't seem to find records on regarding any suppressors or instigators prior to being a poor island nation hell bent on alcoholism. Oh, if only my scientific inklings were wrong! How I wish I wasn't the one that has to break the news to you. Woe is all that I can feel for having to inform you that genetically the Irish are inferior.

The final third of the Chicago population is Polish. The Poles of Chicago are a daft and rotund people but it is not their fault. The DNA has been shaped by thousands of years of unhealthy food. The cold winters of Poland and Chicago force them indoors where they cannot possibly be industrious but have to sit at microscopes and furrow their brows in a vain attempt to understand these things that I have discovered. Even my high minded Libertarian business attitude can't provide enough jobs for these idle drones. Genetically they suffer from 'Polack Slack' and our policy towards helping them past working on the dock and losing weight will forever fail until we come to accept this. It pains me so to break this news to you but down in my genetically superior innards this idea has been borne and I know it to be true. I know it.

The tests indicate that our great nation would probably be more effective if Chicago and its descendents didn't exist at all. Genetically they will forever be poor and stupid, attached to the glass teat clamoring for more concussions while wallowing about in their fetid sties. Drunk and unable to form simple sentences, our once prosperous country will be held back from truly succeeding.

Ball's in your court, James.

Comment Re:It seems like squeegeeing is the wrong approach (Score 2) 203

For a human, using a sponge and squeegee combo is probably the most effective way to clean a window. For a robot, I would imagine that the answer is something more like a pressure washer, with a hood which covers the work area and reclaims the wash water. The water would then be filtered and reused until the particulate count rose too high, at which point it would be flushed and replaced with fresh. A sheeting additive would be used to cause the water to run off without spotting.

This probably wouldn't replace human window washing entirely, but it seems like it has the potential to replace at least some of the washes.

I've often wondered if anyone has ever tried a project to make a building which washes itself, using a robot designed for the building, and a building designed for the robot. I can imagine many problems with such a project without even undertaking it, mostly related to critters taking up residence in the mechanisms and/or tracks, but if it operated continuously that might well eliminate some of those objections. A universal window washing robot has a more complicated task than such a device would.

Did you even read the article? You'll find it discusses how the old World Trade Center Towers had built in devices that were made specifically for the building that would automatically go up and down cleaning it. The only problem was they missed the corners and creases of each pane and the rich people at the top of the building didn't want the grimy borders to their new expensive view of NYC.

It sounds like you have a lot of ideas for building a nice big heavy expensive machine that moves up and down a building. Burst forth and implement your idea, I think you'll find that the the weight, the power and the water feed to these devices will push you towards what has already been implemented and did not do a satisfactory job. Humans had to follow up behind the built in robots to clean spots they had missed.

It's funny, I read articles on Slashdot about how AI is the one thing that threatens man. And we can't even implement AI and pattern recognition to replace a window washer -- oh the incongruity!

Comment Your Thoughts and Use of Post Processing? (Score 3) 35

So I'm not too knowledgeable on photography but one thing I'm aware of is that professional photographers do a lot of post processing. To the point of Adobe Lightroom or higher being so mandatory with DSLRs that they sometimes package it with lenses (especially the ones that distort like a wide angle lens). Do you post process your photos? To what extent? How do you feel about people who use advanced techniques like even adding color to their photos? For example, I came across this photo which was odd to me because I've been to that place and it's beautiful but not like in that photo -- it doesn't need fake pink clouds to be beautiful. It would seem to me a shame to have a tree live 2,000 years and then a human uses a fish eye lens on its knotted trunk to make it seem more old and gnarled and then later adjusts the darkness of the sky to give it a Halloween feel, etc. And then since that's the most artistic shot of it, that's how we remember it.

Comment Be the Change You Wish to See in the World (Score 5, Interesting) 438

When I was younger and I first came across this quote by Mahatma Gandhi:

You must be the change you wish to see in the world.

I always thought it was bizarrely tautological. If you wish something to be different and you personally can make a choice for it under your control to be different, then you make the correct choice. For example, I don't throw a soda can out the window of my car while complaining about pollution on the highway. Other people obviously don't care but I control the drop in the bucket I'm responsible for and I make the ethical choice.

But as I got older, I actually found and still find people that think they should be forced to do it the right way even while complaining about the abuse. Case in point, a friend in the medical profession was actually complaining about tax dodges while setting up his own backdoor Roth IRA. When I asked him about abusing the very rules he was decrying, he simply shrugged and said he doesn't make the rules he just follows them. He acknowledged it's shady as hell but pretty much felt like his hands were tied.

It was deeply troubling ... I get a similar feeling about this article. I understand it is sometimes harder to play by ethical rules than legal rules when everyone around you is benefiting from misconduct but ... it seems this is yet another example of the caste system thriving in India. It's simply stupefying on the "My dad is Li Gang" level.

Medicine

Scientists Discover a Virus That Changes the Brain To "Make Humans More Stupid" 275

concertina226 writes that researchers have found a virus that appears to reduce people’s thinking power and attention span. "Scientists at the Johns Hopkins Medical School and the University of Nebraska have discovered an algae virus that makes us more stupid by infecting our brains. The researchers were conducting a completely unrelated study into throat microbes when they realized that DNA in the throats of healthy people matched the DNA of a chlorovirus virus known as ATCV-1. ATCV-1 is a virus that infects the green algae found in freshwater lakes and ponds. It had previously been thought to be non-infectious to humans, but the scientists found that it actually affects cognitive functions in the brain by shortening attention span and causing a decrease in spatial awareness. For the first time ever, the researchers proved that microorganisms have the ability to trigger delicate physiological changes to the human body, without launching a full-blown attack on the human immune system."

Slashdot Top Deals

I tell them to turn to the study of mathematics, for it is only there that they might escape the lusts of the flesh. -- Thomas Mann, "The Magic Mountain"

Working...