Monday, 18 November 2013

#SpeccyJam progress after day 2/3

The game is well under way now, and it feels good

Been too busy coding for #SpeccyJam so I didn't get a chance to blog end of day 2, this will be a day 2+3 super combo. Right lets get to it...

Day 2

After day 1 I had a very simple game mechanic and render engine, I had to now get to the nitty gritty and start getting the whole game structured.

Short video of Day 2 progress:


The areas I covered:
  • Basic states to the game manager, menu, level start, playing, end of life.
  • Points scored for items collected.
  • Started to manage the HUD, top bar and also 'press key'/'level00'.
  • Improved collision detection and introduced lives.

Day 3

Absolutely buzzing and raring to go, I've managed to squeeze time in my lunch break and after work keen to get this game nailed!

I covered:
  • The player now has to collect a number of items to progress to the next level, 10 feels like a good number, but kept it at 5 for now to speed up test time.
  • I introduced the different game states on Day 2, and today I implemented using them to feedback to the user. When the player collects all the level items, or if they collide with the enemy, I now flash the screen to inform the user.
  • NEW LEVEL MAP! Day 1 I wrote a routine to load in map data from a text file, today I was able to quickly slap in a new level map. Not the most exciting of levels I know, but the level maps alternate as the player progresses through each level.
  • Refined the scoring, 10 points per item collected, then the player gets the remaining time on the clock as points when they complete a level. They also lose 50 points for losing a life.
  • Probably the thing that I'm chuffed about the most is that I introduced a new enemy with simple AI. Same as the old enemy except that it now makes a decision to jump when they reach a drop, or if they've been walking for too long. I introduce them from level 3, and it really takes the game up a step.
  • Added 2 frame sprite animations to the player and enemy. I also flip the pixels depending on if they are moving left or right.
  • Finally I migrated my code to use XNA/MonoGame with the vision of hopefully deploying to Android, OUYA and Silverlight later in the week to make it easier for others to play.


Where am I? Lets sum it up

It's only end of day 3 and I'm very happy indeed. I started off not knowing if I would have time to enter the #speccyjam, and it's turning out great. I genuinely find the game fun and playable. I sometimes catch myself playing it trying to beat the levels when I'm supposed to be testing a feature. It probably just shows how sad I am, but hey, retro gaming is in my blood.

Not sure if I'll be able to get any time tomorrow for progress, but here's some stuff on my mind I want to get done soon:
  • I need to add more maps for other levels.
  • I would like to add a tongue in cheek splash screen.
  • Add the classic ZX Spectrum borders.
  • Add additional enemies, ones that travel horizontally like a bullet or a bat. And maybe one that travels vertically like lava dripping down the map.
  • SOUND! I would like to add sound, I've started to add classic BEEP sounds, but they wont work on anything but a PC so I need to find myself a wav clip to use.
  • If I get time I would like to make an Android version which will require adding touch screen controls.
  • OH... AND I NEED TO THINK OF A NAME!!
Thank you #SpeccyJam, so far you've made my week!

Comment here or get involved on twitter: @rich_lloyd

Sunday, 17 November 2013

I'm having a go at... #SpeccyJam !!

Making a game in the style of a ZX Spectrum game. Can't wait!

That's right, I'm taking a step back from the Amiga dev briefly and I'm making a game for the #SpeccyJam, my first ever jam! The game can be written on any platform, but must be as close to a ZXSpectrum game as possible.

So where do I start?! The jam is only a week long, fitting it around my family and day job, time is tight! Here are the rules: http://www.speccyjam.com/rules/.

Choose a platform... any platform...

My platform of choice is simply a Windows Form application written in C#. I would normally use Unity3D which I highly rate for developing pro games, however, the ZX Spectrum has a unique graphics display. The screen is made up of 32 x 24 attribute blocks, each block is 8x8 pixels. The tricky part is that each block can only display 2 colours at a time from a fixed palette of 15 colours.

If you're not familiar with ZX Spectrum games, then you'll not be aware of the crazyness that happens when sprites clash colours. Personally, unless you can implement these GFX rules, then I don't think it's a true ZX Spectrum replica game. This is why I stepped away from Unity3D and went down the Windows Form route, I felt I would have more control over rendering the screen. Also if I get time, I can just migrate my code to use MonoGame (XNA using Mono), and deploy to multiple platforms like Android, iOS, Linux etc...

Now for the game itself

I don't have a lot of time so it has to be simple. Many hours/days of my youth were spent playing Chuckie Egg and Manic Miner, these are true classics so will use these as my insperation. Not entirely sure where I'll take the game yet, but will be a simple player with a static level(s), collecting things, whilst bad things chase the player.

Day 1:

And we're OFF! First things first, I needed to nail an engine for displaying all the sprites on the screen as a base then build the game upon it. The way I achieved this was to draw the sprites in Photoshop using 2 colours, white + black. These are loaded in and I read the pixels storing them in my own data structure as rows of bytes for each attribute block. Each block has 2 colours, for Paper and Ink. This means I can chuck pixels around my data structure, and my engine will draw the pixels with the correct colours.

Next I built a map engine to read a text file describing a list of 8x8 pixel sprites to use, their colours and their position on the screen. Now this is in place, it will allow me to load multiple maps/levels with ease.

ZX Spectrum has a distinct font, so I drew each character as 8x8 sprites, using the same data structure I was easily able to chuck text on to the screen.

Finally on day 1, I needed a basic character I could move around the screen using the keys. As the map information was already implemented, I was able to quickly add very basic gravity and physics collisions with the scene. As I was on a roll I was able to duplicate the player code to use as a bad guy which ignored the user input. For good measure I quickly put in a collectable sprite, which I rotated through the limited colour palette ever frame, to try and make it look like it was flashing.

Quick screen shot:


Here's a quick video to demo my day 1 progress:


So that was day 1, really really happy with progress. I have the basis of my game, so I can just spend the rest of the week beefing it up, and hopefully make a game not only in the ZX Spectrum style, but actually FUN!

As I write this, I'm actually on day 2, but I've run out of time, so I will blog my progress tomorrow and through out the week.

Comment here or get involved on twitter: @rich_lloyd

Wednesday, 11 September 2013

Amiga assembler tutorials - the wonders of YouTube

I wish I had these sorts of resources back in the 90's...

After some tweets back and forth with a few cool people, I have been shown further resources on the internet for learning about assembler for the Amiga.  I just wanted to share with you a cool YouTube channel Jonas pointed out to me that has several tutorials for Amiga assembler.

If I could embed a whole YouTube channel I would, but here's a link to the channel itself by ScoopexUs: http://www.youtube.com/user/ScoopexUs?feature=g-high-cen

My time at the moment is so limited I haven't had a chance to view all the videos, but I can see there are 9 Amiga programming tutorials, as well as some demo scene stuff.  Check out the channel or here's a couple of snippets...

It starts off really simple with this:



and continues to get more in depth up to this:



Thank you to ScoopexUs for the awesome tutorials, I really hope there are more to come, and thanks to Jonas for pointing these videos out to me, as well as proper reference books.

OK SO... I need to continue being a sponge and learn about the Amiga hardware and soon hopefully I will be able to put together my first proper experience.

Comment here or get involved on twitter: @rich_lloyd

Tuesday, 25 June 2013

Easy68k... Editor / Assembler / Simulator... 68k in Windows!

I have stumbled upon Easy68k, this looks like a great way to learn vanilla 68000 assembly language.  OK so it's in Windows, but surely I'll learn the skills needed for achieving my goal of making a game for the Amiga 500.

For starters it was very easy to install and it comes with some tutorials as well as examples on their website.  The forum on their website is full of people in a similar boat of learning 68000.

So already I've been reading up and now finally have a good environment to have a play about.  I will try and share with you examples of my progress and I think this is a good starting point.

Moving a red blob!

I often find with tutorials and examples when learning technology that the basic stuff is REALLY basic, then all of a sudden the examples are so advance you struggle working out the steps involved.  With that in mind, I wanted to share an example to move a blob about the screen using some user input, the keyboard.  This covers drawing to the screen, and capturing key strokes.  

There is already a Snake type game called Pallet Eater in the examples which is great, but I just wanted to break a few things down.  Simply draw a single red square, and the user can move up / down / left / right.  That's it!


That really is it!

I'm not an expert at assembly (yet), please let me know how I can improve my code.  Any sort of hints and tips would be great. Also if there is a better way to share the code examples please let me know as the code will be getting a lot bigger!

Comment here or get involved on twitter: @rich_lloyd

Here's the code:

*-----------------------------------------------------------
* Title      : Red Blob
* Written by : Rich (http://www.retrorich.co.uk)
* Date       : 24 June 2013
* Description: Moving a red blob around the screen using keys 4,6,8,5
*-----------------------------------------------------------

CR      EQU     $0D
LF      EQU     $0A 

START   ORG    $1000

* --  Make the pen and fill red  -- 
        move.l #$000000FF,d1 
     move.b #80,d0
     trap #15
     move.l #$000000FF,d1
     move.b #81,d0
     trap #15
      
* --  Turn echo off  --
     move.b #0,d1
     move.b #12,d0
     trap #15

* --  Get the time and store it in d5
     move.b #8,d0       
     trap #15
     move.l d1,d5    
   
* --  Set game loop speed
     move.l #5,speed    

* --  Set start position --     
     lea     player,a0     
     move.w #100,(a0)+     Set the start pos to be 100, 100
     move.w #100,(a0) 
        lea     player,a0
        
* -----------------------------------

LOOP    

* -- timing the game loop --

     move.b #8,d0     Re-get the time
     trap #15
     sub.l d5,d1     Subtract the old time from this new time
     cmp.l speed,d1 If less than  hundredths of a second has passed
     blo     LOOP         Loop again until it has
     move.b #8,d0     Now that enough time has passed
     trap #15
     move.l d1,d5     Put the current time in memory for the next loop

* -- grab input --
    *Check to see if a key has been pressed
     clr.l d1
     move.b #7,d0
     trap #15
     tst.l d1
     beq     nokey     Key wasn't pressed, clear movement

    *Read the key that was pressed and find out which key it was
     move.b #5,d0
     trap #15
     
     cmp.b #$35,d1     Key pressed: 5 (down)
     beq     move_down
     cmp.b #$38,d1     Key pressed: 8 (up)
     beq     move_up
     cmp.b #$34,d1     Key pressed: 4 (left)
     beq     move_left
     cmp.b #$36,d1     Key pressed: 6 (right)
     beq     move_right


nokey
        clr.l   d6          Clear any movement
        clr.l   d7
        
continue

        move.b  #11,d0      Clear screen
        move.w  #$ff00,d1
        trap    #15
    
     lea     player,a0     Store current position
     add.w d6,(a0)+     Add any movement to position
     add.w d7,(a0) 
        lea     player,a0       Update current position

        bsr     draw_square     Draw player

        bra     LOOP

* -- key(5) was pressed
move_down
     move.w #0,d6 
     move.w #10,d7 
     bra continue

* -- key(8) was pressed
move_up
     move.w #0,d6
     move.w #-10,d7
     bra continue

* -- key(4) was pressed
move_left
     move.w #-10,d6
     move.w #0,d7
     bra continue

* -- key(6) was pressed
move_right
     move.w #10,d6
     move.w #0,d7
     bra continue

DONE    MOVE.B  #9,D0
        TRAP    #15
    
draw_square
     clr.l d1
     clr.l d2
     clr.l d3
     clr.l d4
     move.w (a0)+,d1
     move.w (a0),d2
     move.w d1,d3
     add.w #10,d3
     move.w d2,d4
     add.w #10,d4
     move.b #87,d0
     trap #15
     rts
 
speed ds.l 1       store game loop speed
player ds.w 2       store player screen pos

Monday, 24 June 2013

Starting to learn assembly language - the journey begins... where do I start?!

Final goal?

Write a game for the Amiga 500.  Bonus goal would be for the same game to run on the Sega Mega Drive (Genesis), but I'll work that out once the first goal is achieved.

Lets start!

I have an Amiga 500, and as mentioned before I'll be following the Amiga Format Bullfrog tutorials for writing a game in assembly language (I'll be writing separate blog posts for each tutorial).  OK so tutorial 1 was pretty straight forward, very basic beginnings pretty much incrementing a register to move a sprite position and understanding some basics.  I've had a quick flick through ahead of the future tutorials and it's pretty obvious that I'm going to have to do some extra research!

OK after some quick googling, I've come across the following websites:

Through those links I was able to download numerous pdf documents, text file tutorials and lots of other people discussing assembler. Great!

A few people had mentioned particular books that they recommended, which then put me on a mission to hit ebay for real world BOOKS! Ebay books for 68000 processor

Real world books I've ended up with, should keep me going for a while!

"Lets get real"

OK so coding on the Amiga 500 is great, I have DevPac 2 and I can run simple examples.  However, this is going to take forever!  Not only is assembly language slow to code (especially when I'm learning), but one of the biggest draw backs is the lack of resources on the machine. As in, I can't just Google something and try it out.  My Amiga 500 is on my desk and sits next to my laptop so yes I can Google stuff, but I have no way to transfer files across other than typing out line by line. What do I do?

Ebay to the rescue again... I've purchased an Amiga 1200 (with a broken floppy drive - hopefully I will blog to explain how I will fix it).  The great thing about the Amiga 1200 is that you can connect it to the internet, and also use a compact flash card as a hard drive!! 4Gb!!  It's still in the post, but I expect I will try and code on the A1200 and once I'm up to speed I'll try and create boot disks with my tests and trials for the A500.  Remember my goal is to write a game for the Amiga 500 not Amiga 1200!


What next?

I've read through most of 2 68000 books, and I think it's becoming clear that I'm learning vanilla 68k assembly language.  I need some Amiga specific references.  I'm using DevPac 2, but maybe I need to get my hands of DevPac 3, AsmOne or some other assembler package?  And then find a reference + tutorials for that package?

I have stumbled upon Easy68k, this is an Editor, Assembler and Simulator for the 68000 that runs in Windows.  Again this looks like just vanilla 68k, but looks like a great way to learn the basics without crashing my Amiga ever time!

Do you still code in Assembler?!

Would love to hear from anyone who still codes in assembler, especially for the Amiga machines.  Or maybe if you used to?  Any hints or tips you could recommend?

Comment here or get involved on twitter: @rich_lloyd

Sunday, 16 June 2013

It's 2013 man, why bother learning assembler for the Amiga?!

OK so I'm a little late to the party (over 20 years), but I've set myself the goal to learn assembly language for the Amiga (68000 processors) and wanted to share my experience with you.

At the age of 13 I was so excited to see a tutorial in Amiga Format called 'How to program your own games in assember', this was the stepping stone for me to become my dream, a games programmer.  Sadly as a kid, I struggled, I already knew BASIC and AMOS, but Assembler was something else.  The internet didn't exist, I was too young to realise there would be books on the topic, and didn't know anyone in the same boat I could share learning with.  I was alone.  I gave up, but it's always bugged me.

Now I'm an experienced programmer, I became professional in the late 90's and my dream of coding games came true, but I never did learn assembly language.  Of course I didn't need to, the industry moved on, easier and more productive languages are now used.  Games I write for clients these days use Unity3D or XNA/MonoGame and the teams I work with can produce sophisticated 3D worlds.

"Games ain't what they used to be"

Technology today is mind blowing, and the games produced today are masterpieces. However I still feel most games today miss the magic of the games made in the early 90's, especially on the Amiga.  Is it just my age or did Amiga games really have something different about them?  To prove I'm not wearing rose tinted glasses I've started to research some of the old classics.  Google and youtube are great, but I've also fired up my Amiga 500 and properly reliving the experience.  I wanted to understand more about the all round hero Amiga machine, and how the games were written.  Whilst hunting through my old stuff, I came across my Amiga Formats (issues 39-44) with the tutorials I struggled with as a kid, I found all the cover disks, including the full version of DevPac 2.

My Amiga 500 - awesome machine


I'm about to learn assembly language, how hard can it be? Right? Game ON!

Challenge accepted.  I'm aiming to blog about my experience with each tutorial, and then hopefully sum up the whole journey.  I have my Amiga 500 now set up on my desk, all issues of Amiga Format tutorial with all the cover disks (I hope they all still work).

Can't wait to get stuck in to the tutorial I really hope it can teach me everything I need to know.  Having new knowledge combined with my career experience, I would love to write a game for the Amiga!

I've bought this book on Amazon 'An introduction to 68000 Assembly Language', it's very brief, but it does give me the list of commands available.
Very brief book - but perfect for when I start delving deeper...

Do you still code in Assembler?!

Would love to hear from anyone who still codes in assembler, especially for the Amiga machines.  Or maybe if you used to?  Any hints or tips you could recommend?  Did you complete the tutorials?  Did it kick start your career?

Comment here or get involved on twitter: @rich_lloyd