Jump to content
  • entries
    5,043
  • comments
    2,756
  • views
    1,821,695

Red elephant


atari2600land

205 views

I had a hard time trying to go to sleep last night. I finally fell asleep at about midnight and woke up at about 8 a.m. or so. I decided to attempt to put a moving red elephant in the game. But I had a problem. The widest an object can be is 8 pixels. So I needed to put two objects side by side to make a decent looking elephant. At first I had to double the x and y positions for the two things and make x's position 7 pixels to the right of the left half of the elephant sprite. Having to find just the right way to put two sprites side by side with no weirdness in the middle of it was a pain. But once I did that, I thought "Instead of using precious lisu's, why not just make it so when it comes time to draw the second sprite, just increase the x's position by 7." Skeptical of myself, I thought I wasn't going to be able to do this but lo and behold, I had my elephant moving down the screen with animated legs.

celeryelephant.png.d0d363ed97c3a536d4e0844e56358417.png

Each half of the elephant is 8 pixels wide, making for a 16-pixel wide thing, but in order to not mess things up, I don't think I can move it left and right without causing havoc. Which is okay because I only wanted the elephant to move down the screen anyway. If you count the pixels, you'll find it's only 14 pixels wide. The extra two pixels are for boundary and have been zeroed out.

 

So now the next things to do are:

  • make the elephant come down at a random x position (one of 16 x positions should be a wide enough play area.
  • put the celery in the game at the bottom.
  • make celery able to move its x position.
  • collision detection.
  • and a score.

 

I changed the font of the title screen. I don't want every game I do to just use Arial, so I try to mix fonts up a little so they don't look the same.

celerytitlescreen.png.ecfcd4948a4954b6dceb58b10de6445d.png

I really wanted the background to be light blue while having the middle stripes of the celery be light green, but I guess I can't.

  • Like 1

1 Comment


Recommended Comments

Are you using blit code? You don't have to be limited to 8 pixels, however obviously the bitmap is in groups of 8. Here's an example from my shark game:

 

sharklGraphic:
    .byte    %00000011 
    .byte    %00000000
    .byte    %11001111
    .byte    %00000011
    .byte    %00111111
    .byte    %11111111
    .byte    %11000011
    .byte    %00000000

 

on first sight, it doesn't look like anything, but when called...:

 

; shark
    ; blue
    li $80
    lr 2, A
    li $C3
    lr 1, A
    ; 4 y position
    lisu    2
    lisl    4
    lr A, S
    lr 4, A
    ; 3 x position
    lisu    2
    lisl    3
    lr A, S
    lr 3, A
    ; 5 width
    li 16
    lr 5, A
    ; 6 height
    li 4
    lr 6, A
    lisu 3
    lisl 0
    lr A, S
    ci %00000001
    bz sharkr
    dci    sharklGraphic
    pi blit

 

[other code]

 

sharkr:
    dci sharkrGraphic
    pi blit

 

The width that is saved into register 5  (or height in register 6) can be as big as you want* I kept it to a multiple of 8 for ease, but shouldn't be effected by it at all. It simply reads the first 16 bits (two bytes in this case) then moves on to the next line. In my case I've used 4 lines, so its 8 bytes of 8 bits which is pretty uniform, but it could be any number of bytes. For ease in code the bitmap could be grouped like this:

 

sharklGraphic:
    .byte    %00000011, %00000000
    .byte    %11001111, %00000011
    .byte    %00111111, %11111111
    .byte    %11000011, %00000000

 

In the same game my scoring font looks like this:

 

n0g:
    .byte    %01101001
    .byte    %10011001
    .byte    %10010110

 

Again, its clearly not like that in game, its loaded for blit like this:

 

    ; 5 width
    li 4
    lr 5, A
    ; 6 height
    li 6
    lr 6, A

 

So a byte of bitmap is used for 2 lines.

 

There is however one massive benefit of doing it how you've done it: You could make animations where only one side of the graphic changes but the other stays the same. Say if you wanted the elephant to move its trunk in a certain way but keep the back end the same graphic (or vice-versa) you can get multiple graphic variations with potentially less byte cost, check a value, branch off like I do for directions, and dci the other graphic instead.

 

*obviously no point being more than 102 due to resolution, unless you are doing something crazy I guess.

Lisu 3 Lisl 0 in this case was used to check for shark direction, hence the branching code at the end.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...