It’s a pretty common task to get the distance between 2 points. Maybe you’re wanting to see if two points are close enough to have…
It’s a pretty common task to get the distance between 2 points. Maybe you’re wanting to see if two points are close enough to have…
There are two ways to measure angles. You probably learned to measure angles in degrees early in school. A circle has 360 degrees, a perfect…
At first glance the Pythagorean Theorem doesn’t appear to relate to game development. But we’ll see in a bit that it does. First though, let’s…
Creating the next great side scroller? Well, you’ll need a scrolling background. And if you’re programming in Java, here’s an easy way to do it.
Here’s a little demo of what we’re going to create. What’s happening is that there are two copies of the same image scrolling from the right to left. As one copy gets all the way off the left edge it leapfrogs back over to the right side. Normally they’d be the same, but it makes more sense on the demo for the two copies to be different colors.
The black box is the screen. Everything to the right or left of the box is happening off screen.
Click to start and click to stop.
This is a follow up to an earlier post where we created a scrolling background in Flash using ActionScript. This time we’re going to do the same thing, but using Python and Pygame.
Take a look at your favorite game. Odds are good that there is a scrolling background of some type. Think Super Mario Brothers.
Mario is a bit different than what we’re after though. The background in Mario is a single graphic that scrolls as Mario moves through the world. What we want is a scrolling background that loops forever. We’re going to scroll horizontally like a platform jumping game, but the same concept works vertically.
Thanks to Pygame, there’s a quick and easy method to get the dimensions of an image. You just have to load it into a Surface…
Some games, I’m thinking tower defense, need to give the player the ability to drag symbols around. But you don’t always want to give the player free reign to drag it anywhere. Maybe you want them to only be able to position symbols in a grid. That’s what we’ll create here using ActionScript 3.
This is what we’re going to be creating. Try dragging the green square. It will snap so that it’s always in one of the grid squares.
Earlier this week I Googled for how to find the dimensions of an image using Java, and most of the solutions were way more complicated…
Want to create a random color in Java? With a bit of math, plus Math.random(), it’s pretty easy.
Colors on the computer are made up of a red, green, blue triplet; typically called RGB. And each of the 3 pieces can be in the range from 0 to 255. Java also allows us to create a color using floats for the values in the range of 0.0 to 1.0, or from 0% to 100% of that color. We’re going to use the floats.
As an example, pure red will have an R value of 1.0, a G value of 0.0, and a B value of 0.0.
So we know what numbers we need, but we want ’em random.