All posts by Ryan Lambie

Coding Space Invaders’ disintegrating shields | Wireframe #9

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/coding-space-invaders-disintegrating-shields-wireframe-9/

They add strategy to a genre-defining shooter. Andrew Gillett lifts the lid on Space Invaders’ disintegrating shields.

Wireframe 9 Space Invaders

Released in 1978, Space Invaders introduced ideas so fundamental to video games that it’s hard to imagine a time before them. And it did this using custom-made hardware which by today’s standards is unimaginably slow.

Space Invaders ran on an Intel 8080 CPU operating at 2MHz. With such meagre processing power, merely moving sprites around the screen was a struggle. In modern 2D games, at the start of each frame the entire screen is reset, then all objects are displayed.

For Space Invaders’ hardware, this process would have been too slow. Instead, each time a sprite needs to move, the game first erases the sprite from the screen, then redraws it in the new position. The game also updates only one alien per frame — which leads to the effect of the aliens moving faster when there are fewer of them. These techniques cut down the number of pixels which need to be updated each frame, from nearly 60,000 to around a hundred.

Wireframe 9 Space Invaders

One of Space Invaders’ most notable features is its four shields. These provide shelter from enemy fire, but deteriorate after repeated hits. The player can take advantage of the shields’ destructible nature — by repeatedly firing at the same place on a shield’s underside, a narrow gap can be created which can then be used to take out enemies. (Of course, the player can also be shot through the same gap.)

The system of updating only the minimum necessary number of pixels works well as long as there’s no need for objects to overlap. In the case of the shields, though, what happens when objects do overlap is fundamental to how they work. Whenever a shot hits something, it’s replaced by an explosion sprite. A few frames later, the explosion sprite is deleted from the screen. If the explosion sprite overlapped with a shield, that part of the shield is also deleted.

Wireframe 9 Space Invaders

Here’s a code snippet that shows Andrew’s Space Invaders-style disintegrating shields working in Python. To get it running on your system, you’ll need to install Pygame Zero — you can find full instructions here. And download the above code here.

The code to the right displays four shields, and then bombards them with a series of shots which explode on impact. I’m using sprites which have been scaled up by ten, to make it easier to see what’s going on.

We first create two empty lists — one to hold details of any shots on screen, as well as explosions. These will be displayed on the screen every frame. Each entry in the shots list will be a dictionary data structure containing three values: a position, the sprite to be displayed, and whether the shot is in ‘exploding’ mode — in which case it’s displayed in the same position for a few frames before being deleted.

The second list, to_delete, is for sprites which need to be deleted from the screen. For simplicity, I’m using separate copies of the shot and explosion sprites where the white pixels have been changed to black (the other pixels in these sprites are set as transparent).

The function create_random_shot is called every half-second. The combination of dividing the maximum value by ten, choosing a random whole number between zero and the maximum value, and then multiplying the resulting random number by ten, ensures that the chosen X coordinate is a multiple of ten.


Wireframe 9 Space Invaders
Wireframe 9 Space Invaders

Andrew’s Space Invaders shields up and running in Pygame Zero.

In the draw function, we first check to see if it’s the first frame, as we only want to display the shields on that frame. The screen.blit method is used to display sprites, and Pygame Zero’s images object is used to specify which sprite should be displayed. We then display all sprites in the to_delete list, after which we reset it to being an empty list. Finally we display all sprites in the shots list.

Wireframe 9 Space Invaders

In the update function, we go through all sprites in the shots list, in reverse order. Going through the list backwards avoids problems that can occur when deleting items from a list inside a for loop. For each shot, we first check to see if it’s in ‘exploding’ mode. If so, its timer is reduced each frame — when it hits zero we add the shot to the to_delete list, then delete it from shots.

If the item is a normal shot rather than an explosion, we add its current position to to_delete, then update the shot’s position to move the sprite down the screen. We next check to see if the sprite has either gone off the bottom of the screen or collided with something. Pygame’s get_at method gives us the colour of a pixel at a given position. If a collision occurs, we switch the shot into ‘exploding’ mode — the explosion sprite will be displayed for five frames.

You can read the rest of the feature in Wireframe issue 9, available now in Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from us – worldwide delivery is available. And if you’d like to own a handy digital version of the magazine, you can also download a free PDF.

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusives, and for subscriptions, visit the Wireframe website to save 49% compared to newsstand pricing!

The post Coding Space Invaders’ disintegrating shields | Wireframe #9 appeared first on Raspberry Pi.

How musical game worlds are made | Wireframe #8

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/how-musical-game-worlds-are-made-wireframe-8/

88 Heroes composer Mike Clark explains how music and sound intertwine to create atmospheric game worlds in this excerpt from Wireframe issue 8, available now.

Music for video games is often underappreciated. When I first started writing music in my bedroom, it took me a while to realise how much I was influenced by the worlds that came from my tiny CRT TV. A couple of years ago, I was lucky enough to be approached by Bitmap Bureau, an indie startup who hired me to compose the music for their first game, 88 Heroes.

88 Heroes is a platformer styled like a Saturday morning cartoon. Interestingly, cartoon soundtracks have a lot in common with those for stage productions: short musical cues accompany the actions on screen, so if someone violently falls downstairs, you hear a piano rolling down the keys. This is called ‘mickey mousing’ in cartoons, but we hear similar things in film soundtracks.

Take Raiders of the Lost Ark, scored by John Williams: for every heroic rope swing, leap of faith, or close encounter with danger, the main theme can be heard powering through the dissonances and changing rhythms. It fills the audience with hope and becomes synonymous with the lead character – we want to see him succeed. Let’s not forget the title theme. Every time you see the Star Wars logo, does that grand title theme play in your head? It’s the same with video games. The challenge here, of course, is that players often leave the title screen after three seconds.

Three seconds is all you need though. Take Super Mario World’s soundtrack, composed by Koji Kondo. Many of its levels have the same leading melody, which changes subtly in tonality and rhythm to create the appropriate mood. The most repeating part of the melody is four bars long, but we hear it in so many forms that we only need the first two bars to know where it’s from. In classical music, this is called ‘variations on a theme’. In video games, we call it a ‘sonic identity’.

Action platformer 88 Heroes, featuring music by Mike Clark.

How a picture should ‘sound’

Sonic identity informed my approach to the 88 Heroes soundtrack. The title screen tells us that an unknown group is going to save the day. I first thought about unlikely heroes who end up on an adventure, and Back to the Future, scored by Alan Silvestri, sprang to mind. The second inspiration came from traditional superheroes, like Superman. I composed a melody which travels between the first and fifth notes in the scale (in this case C and G), with little flourishes of the notes in-between. It’s a triumphant, heroic melody.

This concept helps to connect these worlds beyond their visuals. It took a long time for games to evolve into the cohesive open-world sandboxes or MMOs we see today; the technology that masked loading screens to create a seamless experience was unheard of in the 1990s, so a melody that you hear in different ‘costumes’ gives these games a sense of cohesion.

Intelligent instruments

What if you have levels (or worlds) so big that some areas need to be loaded? That’s where non-linear composition comes in. Banjo-Kazooie, released for the N64 in 1998, was among the first 3D games to feature dynamic music. It used a technique called MIDI channel fading. MIDI stands for Musical Instrument Digital Interface; think of it as a universal language for music that is played back in real time by the hardware. As you walk into caves, fly in the sky, or move near certain characters, instruments fade in and out using the different MIDI channels to mimic the atmosphere, give the player an audio cue, and build and release tension.

Learning how to write music that changes as you play might seem impossible at first, but it becomes second nature once you understand the relationship between every instrument in your composition. Many digital audio workstations, like Logic and FL Studio, let you import MIDI data for a song (so you have all the notes in front of you) and set the instruments yourself. Try slowly fading out or muting certain tracks altogether, and listen to how the mood changes. What could this change represent in a video game? It’s like when you’re riding Yoshi in many of the Mario games; the fast bongos come in to represent the quick-footed dinosaur as he dashes at high speeds.

Undertale’s soundtrack blends analogue synth instruments with a plethora of real instruments to help create emotion.

Music is used to evoke emotions that wouldn’t be possible with visuals alone. Beep: A Documentary History of Game Sound shows a six-second video of a boat accompanied by two soundtracks; one is a light and happy guitar piece, the other a grating, scary, orchestral dissonance. Through these two extremes, the music creates the mood by itself. I remember playing Metroid Prime and finding the Chozo Ghost enemies rather scary, not because of their appearance, but because of the unnerving music that accompanies them. Music and sound design are one and the same. Think about what feelings you can create by taking music away entirely — it’s a great way to create tension before a boss battle or pivotal plot point, and it really works. In Undertale, scored by Toby Fox, there are times when the music stops so abruptly during NPC dialogue that you feel shivers down your spine.

So, what if you’re trying to come up with some game music, and you have writer’s block? Well, the next time you play a new game, turn the sound off. As you’re playing, focus on how the story, art, or characters make you feel, and focus on the emotions the game is trying to convey. Then, think of a time when a song made you feel happy, sad, joyful, anxious, or even frightened. Maybe you can use the music to create the mood you want for that game, as opposed to what the game makes you feel. By finding these emotions and understanding how they can change, you’ll be able to write a score that helps strengthen the immersion, escapism, and player investment in your game.

You can read the rest of the feature in Wireframe issue 8, available now in Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from us – worldwide delivery is available. And if you’d like to own a handy digital version of the magazine, you can also download a free PDF.

Markets, moggies, and making in Wireframe issue 8

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusives, and for subcriptions, visit the Wireframe website to save 49% compared to newsstand pricing!

The post How musical game worlds are made | Wireframe #8 appeared first on Raspberry Pi.

Inside the Dreamcast homebrew scene | Wireframe issue 7

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/wireframe-7-inside-dreamcast-homebrew-scene/

Despite its apparent death 17 years ago, the Sega Dreamcast still has a hardcore group of developers behind it. We uncover their stories in this excerpt from Wireframe issue 7, available now.

In 1998, the release of the Dreamcast gave Sega an opportunity to turn around its fortunes in the home console market. The firm’s earlier system, the Saturn, though host to some beloved titles, was running a distant third in sales behind the Nintendo 64 and PlayStation. The Dreamcast, by contrast, saw a successful launch and quickly became the go-to system for arcade-quality ports of fighting games, among other groundbreaking titles like Seaman and Crazy Taxi.

Unfortunately for fans, it wasn’t to last. The Dreamcast struggled to compete against the PlayStation 2, which launched in 2000, and at the end of March 2001, in the face of the imminent launch of the Nintendo GameCube and Microsoft’s new Xbox, Dreamcast left the stage, and Sega abandoned the console market altogether.

None of this stopped a vibrant homebrew development scene springing up around the console in Sega’s place, and even years later, the Dreamcast remains a thriving venue for indie developers. Roel van Mastbergen codes for Senile Team, the developers of Intrepid Izzy, a puzzle platformer coming soon to the PC, PS4, and Dreamcast.

Of the port to Sega’s ageing console, van Mastbergen tells us, “I started this project with only the PC in mind. I’m more used to developing for older hardware, though, so I tend to write code with low CPU and RAM requirements by force of habit. At some point I decided to see if I could get it running on the Dreamcast, and I was happy to find that it ran almost perfectly on the first try.”

It runs at a lower resolution than on PC, but Intrepid Izzy still maintains a smooth 60fps on Dreamcast.

One of the pluses of the Dreamcast, van Mastbergen points out, is how easy it is to develop for. “There are free tools and sufficient documentation available, and you can run your own code on a standard Dreamcast without any hardware modifications or hacks.”

Games burned to CD will play in most models of unmodified Dreamcast, usually with no extra software required. While this doesn’t result in a huge market — the customer base for new Dreamcast games is difficult to measure but certainly small — it makes development for original hardware far more viable than on other systems, which often need expensive and difficult-to-install modchips.

Many of the games now being developed for the system are available as digital downloads, but the state of Dreamcast emulation lags behind that of its competitors, with no equivalent to the popular Dolphin and PCSX2 emulators for GameCube and PS2. All this makes boxed games on discs more viable than on other systems — and, in many cases, physical games can also become prized collectors’ items.

Intrepid Izzy is developed with a custom code library that works across multiple systems; it’s simple to downscale PC assets and export a Dreamcast binary.

Kickstarting dreams

By now, you might be asking yourself what the point of developing for these old systems is — especially when creating games for PC is a much easier and potentially more profitable route to take. When it comes to crowdfunding, though, catering to a niche but dedicated audience can pay dividends.

Belgian developer Alice Team, creators of Alice Dreams Tournament, asked for €8000 in funding to complete its Dreamcast exclusive, which began development in 2006. It eventually raised €28,000 — more than treble its goal.

Intrepid Izzy didn’t quite reach such dizzying heights, only just meeting its €35,000 target, but van Mastbergen is clear it wouldn’t have been funded at all without the dedicated Dreamcast base. “The project has been under-funded since the beginning, which is slightly problematic,” van Mastbergen tells us. “Even so, it is true that the Dreamcast community is responsible for the lion’s share of the funding, which is a testament to how well-loved this system still is.”

You can read the rest of the feature in Wireframe issue 7, available in Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from us – worldwide delivery is available. And if you’d like to own a handy digital version of the magazine, you can also download a free PDF.

Face your fears in the indie horror, Someday You’ll Return.

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusives, and for subscriptions, visit the Wireframe website to save 49% compared to newsstand pricing!

The post Inside the Dreamcast homebrew scene | Wireframe issue 7 appeared first on Raspberry Pi.

From Wireframe issue 5: Breakthrough Brits in conversation

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/wireframe-issue-5/

BAFTA-recognised developers Adrienne Law and Harry Nesbitt share their thoughts on making games, work-life balance, and more in this excerpt from Wireframe issue 5, available from today.

It’s certainly ‘woollies and scarf’ weather now, but the low-hanging sun provides a beautiful backdrop as Adrienne and Harry make their daily short walk from home to the ustwo games office. In late 2018, Adrienne Law and Harry Nesbitt were both recognised by BAFTA as Breakthrough Brits: an award given by BAFTA to new and emerging talent across a variety of art and entertainment industries. But that’s not the only thing they have in common — Adrienne and Harry work in the same office and are even housemates.

Monument Valley 2 screenshot

Monument Valley 2

Adrienne is a producer at ustwo games, most recently on the acclaimed puzzler Monument Valley 2. Harry doesn’t work for ustwo, but he’s a regular fixture there, taking a spare desk to work as the lead developer and artist for Alto’s Adventure and its sequel, Alto’s Odyssey.

Alto’s Odyssey screenshot

Alto’s Odyssey

As two professionals early in their careers in an ever-evolving industry, Adrienne and Harry find themselves with much in common, but the routes that led them to working and living together were very different. The pair agreed to take an hour out of their work schedules to speak to Wireframe, and to each other, about their personal experiences of game development, how it feels to release a game, work-life balance, and the potential of games to affect and enrich lives.

Adrienne Law: My route into the games industry was semi-accidental. I played games a lot when I was a kid but didn’t know there was an industry as such to go and work in. I did an English degree thinking that might possibly set me up for going into some kind of creative, story-driven field, which was what interested me. After that, I spent a few years working different jobs — I was a teaching assistant, I worked in finance, retail, marketing, and was circling around trying to get into film and TV industries.

Eventually, I got to the point where I went onto job sites and searched for “production assistant” and that’s where I found a production assistant role going at ustwo games. I thought, “Oh! Production is a thing in games! I didn’t know that.” I decided to just go for it. I ended up having a few interviews with ustwo — I think they were worried because I was quite quiet, and they weren’t sure how much I would step into the role — but they let me through the door and gave me a chance. I’ve been here ever since. I never set out to be in the games industry, but I think I’d been gaining a lot of skills and had an awareness of the medium, so those things combined into making me a good candidate for the role.

I went to an all girls’ school that specialised in maths and science, so there was no reason that I would have thought I couldn’t work in tech, but the school didn’t push the idea of working in tech and coding. I think if I had been aware of it from a younger age, I would have been a programmer.

Harry Nesbitt

Harry Nesbitt: I’ve always thought about working in games. From a young age, I had an interest in how games were made from an artistic standpoint. I would always look up who was responsible for the concept art. Concept art as a job was something I was aware of from a very young age.

Around 2006, when I started at university, indie games weren’t in the mainstream, and making games in your own bedroom wasn’t as popular an idea. When I discovered Unity, I thought “Oh, I can download this for free, and I can learn all the basics online.” I saw examples of illustrators who were downloading it and making cool, interesting little projects — almost like little art pieces — bringing their illustrations to life. It made me realise I could have a play with that. My knowledge of the basics of JavaScript and web development helped me pick up the coding side of things a little bit more easily.

When it came to making Alto’s Adventure, I knew a little bit of Unity and had been playing with it for about 12 months, so I realised I could at least be playing around with it, seeing what’s possible and using it as a way to demonstrate certain ideas.

Within a very short space of time, less than a week maybe, I’d been able to put together a basic prototype of the core systems, such as the terrain generation, basic player physics, even some effects such as particles and Alto’s scarf. It took another year and a half from there to get it finished, but online resources gave me what I needed to eventually get the game made. It’s not necessarily an experience I’d want to repeat though!

You can read the rest of this fantastic feature in Wireframe issue 5, out today, 17 January, in Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from us — worldwide delivery is available. And if you’d like to own a handy digital version of the magazine, you can also download a free PDF.

The cutest Wireframe cover to date!

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusives, and for subscriptions, visit the Wireframe website to save 49% compared to newsstand pricing!

The post From Wireframe issue 5: Breakthrough Brits in conversation appeared first on Raspberry Pi.

Wireframe 2: The Blackout Club, Battlefield V anxiety, and more

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/wireframe-2/

Momentum firmly established, we’re back with our brilliant second issue of Wireframe — the magazine that lifts the lid on video games.

And yes, we are continuing to write ‘video games’ as two words.

Blacking out

In our sophomore edition, you’ll discover all manner of great features, guides, reviews, and everything else you could wish for. In an exclusive interview, BioShock 2 director Jordan Thomas talks about The Blackout Club, his new co-operative horror game – which also features on our fantastic front cover! With inspiration coming from the likes of Stranger Things, you just know The Blackout Club is going to be something special.

We also hear from Battlefield V’s Creative Director Lars Gustavsson in a candid discussion about his own personal excitement — and apprehension — surrounding the launch of DICE’s latest in its nearly 20-year-old series.

And a lot more

Is that all? Of course not. Thomas Was Alone and Subsurface Circular creator Mike Bithell shares his personal perspective on the ever-changing shape of video games.

Issue 2 also takes an extended look at an RPG’s journey from tabletop to screen: it’s not easy to bring the likes of Cyberpunk 2020 to the world of video games, and CD Projekt Red, Chris Avellone, and others tell us just why that is.

We’re just spoiling you now, but there’s plenty more besides, such as:

  • The maths behind matchmaking and video game economics
  • The changing face of Mega Man, an enduring 8-bit icon
  • An indie game’s path from Japanese restaurant to Nintendo eShop
  • The simple yet effective AI behind Galaxian’s angry aliens

All of this is joined by news, previews, and reviews of everything gaming has to offer.

Buy Wireframe issue 2

Physical copies of Wireframe are available now in WHSmith, Tesco, and all good independent UK newsagents. Of course, we don’t like to limit your choices, so you’re able to buy direct from us, with worldwide delivery available.

There’s also the option to download issue 2 a free PDF if you’d like a handy digital version.

Subscription options!

Fancy putting your feet up and letting Wireframe come directly to you? In that case, you should take a look at our subscription options: pick up a sample six issues for a bargain price, subscribe for a full year, or get the digital edition directly to your smart device via our Android and iOS apps. To find out how to save up to 49% on Wireframe’s print edition, head to wfmag.cc/subscribe.

wireframe magazine

See you again in two weeks!

A wild HackSpace magazine appeared

HackSpace magazine issue 13 is also out today, and it’s pretty sweet. Check it out here!

HackSpace issue 13 front cover

The post Wireframe 2: The Blackout Club, Battlefield V anxiety, and more appeared first on Raspberry Pi.

Wireframe issue 1 is out now!

Post Syndicated from Ryan Lambie original https://www.raspberrypi.org/blog/wireframe-issue-1/

Wireframe is our new twice-monthly magazine that lifts the lid on video games. In Wireframe, we look at how games are made, who makes them, and how you can make games of your own. And today, we’re releasing our very first issue!

Wireframe: the new magazine that lifts the lid on video games

Uploaded by Raspberry Pi on 2018-11-07.

The inaugural issue

In issue 1, Far Cry 4 director Alex Hutchinson talks to us about going indie. We look back at the British games industry’s turbulent early years; we explore how curves and probabilities shape the games we play; and we get hands-on with Nomada Studio’s forthcoming ethereal platformer, Gris.

Wireframe magazine

Plus:

  • Jessica Price on the state of game criticism
  • Portal squeezed onto the Commodore 64
  • Treasure — the iconic game studio at 25
  • Gone Home’s Kate Craig on indie game design workarounds
  • And much, much more…

About Wireframe magazine

Cutting through the hype, Wireframe takes a more indie-focused, left-field angle than traditional games magazines. As well as news, reviews, and previews, we bring you in-depth features that uncover the stories behind your favourite games.

Wireframe magazine

And on top of all that, we also help you create your own games! Our dedicated Toolbox section is packed with detailed tutorials and tips to guide you in your own game development projects.

wireframe issue 1 cover

Raspberry Pi is all about making computing accessible to everyone, and in Wireframe, we show you how programming, art, music, and design come together to make the video games you love to play — and how you can use these elements to build games yourself.

Free digital edition

We want everyone to enjoy Wireframe and learn more about creating video games, so from today, you’ll also be able to download a digital copy of issue 1 of Wireframe for free. Get all the features, guides, and lively opinion pieces of our paper-and-ink edition as a handy PDF from our website.

Wireframe in the wild

You can find the print edition of Wireframe issue 1 in select UK newsagents and supermarkets from today, priced at just £3. Subscribers also save money on the cover price, with an introductory offer of twelve issues for just £12.

For more information, and to find out how to order Wireframe from outside the UK, visit wfmag.cc.

The post Wireframe issue 1 is out now! appeared first on Raspberry Pi.