View Single Post
Old 31 October 2017, 23:00   #1
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Writing a game sprite driver

Hi All, I'm new here.

Back in the day around 91/92 I used to do a bit of assembly on the Amiga. Well a few weeks ago I went up into the attic and found my old trusty A500 with my AR3 Cart and was amazed it still worked, I was surprised at how familiar I was with it so I kind of have the coding bite back again. Around the time of my coding days I mainly had aspirations to be a game developer but found myself doing demo/cracktro routines which was kinda cool at the time but didn't do much for my employment opportunities.

So here I am and I have my WinUAE setup perfectly and my Mayflash Joystick adapter all up and running and it is just like the old days. One thing I attempted to do back then was design/build a sprite driver routine. Now what I mean by this is not just how many sprites I can get on screen, I mean how many sprites I can get on screen but have full collision detection of arbitrary objects just like a running game would have - I found it particularly mind bending back in the day so I guess I just might not have been old/wise enough to do it.

That said, I want to try and resurrect the challenge so I've had a little think over a couple of hours and came up with some thoughts below around design of the Sprite definitions - it's really just a brain dump but I was wondering if the wheel had already been invented by someone else before I start coding that I could review? Any code I write I'm happy to share with the community. Any tips from seasoned devs are most welcome!!!

When I came across the forum I was looking for platformer games that hadn't been ported to the Amiga so the Rygar thread popped up which has been really fascinating to read, I've kind of had that game in my head as I wrote this as I loved it in the arcades (I even tried to port it myself to the GBA back in 2002 in ARM without success).

Here goes... starting with events that are found in a tile map which generate sprites. Imagine this being a world that a player can move around in / think Turrican, Robocod 2, Rygar etc

The appearance of sprite data depends upon the triggering of events in a map world.

Sprited can be created by any of the following:
-- Timer based events
Based on a timer counter that increments from when the world begins.
(Think of when the baddie appears on Bubble Bobble)

-- Map point reached or is visible
Sprite is generated when a particular map point or counter has been reached in the world.

-- Other sprite conditions
Sprite conditions such as sprites being destroyed, created or collided.

Sprites that are created are tagged with formations, such as:

(1) Move Left, Right, Up or Down and do not pass obstacle
(2) Move Left and Right and jump over obstacle (think Rygar)
(3) Move Left and Right and fall off obstacle
(4) x/y formation list - (so think of shoot'emup attack formations)
(5) Move Left, Right, Up or Down and pass obstacle (think bullets)
(6) Sprite can move but cannot move through obstacles (Rygar)
(7) Others..... that I can't think of.


When a Sprite is created or is moving around the following properties would need to be maintained. I define word 'sprites' as being either part of the playfield that are animating or as objects that are moving / traversing the playfield or other sprites.

Sprite objectId - (var decimal) * Pointer to the sprite Object Id
Sprite frameIndex - (var decimal) * Pointer to the sprite type
Sprite frameNumber - (var decimal) * Pointer to the current animation frame
Sprite frameMoveSpeed - (var decimal) * Sprite move speed, default or defined in sprite object
Sprite frameAnimSpeed - (var decimal) * Sprite animation speed, default or defined in sprite object
Sprite active - (boolean) * Is the sprite currently on screen
Sprite controlJump - (boolean) * Can the sprite be controlled? Jumping perhaps?
Sprite controlAttack - (boolean) * Can the sprite be controlled? When attacking?
Sprite controlFall - (boolean) * Can the sprite be controlled? when Falling?
Sprite controlCollide - (boolean) * Can the sprite be controlled when colliding?
Sprite controlCreating - (boolean) * Can the sprite be controlled when being created?
Sprite controlDestoyed - (boolean) * Can the sprite be controlled when destroted?
Sprite CollisionLive - (boolean) * Is the sprite collision live, i.e. can it be hit?
Sprite isEnemy - (boolean) * Is this sprite classed as an enemy? Could be important.
Sprite destroyedEvent - (var eventId) * Event to generate on sprite being destroyed
Sprite createdEvent - (var eventId) * Event to generate on sprite being created
Sprite collideEvent - (var spriteId, eventId) * Event to generate on sprite colliding
Sprite isColliding - (boolean) * Is the sprite colliding with another?
Sprite isCollidingWith - (array SpriteIds) * This Sprite is colling with these other sprites.
Sprite xPos - (var decimal) * X Position on screen
Sprite yPos - (var decimal) * Y Position on screen



Sprite Objects

Every sprite has the following attributes that are pre-defined.


Sprite Id - (const decimal) * Unique sprite ID, referenced in maps and formations.
Sprite isTile - (boolean) * This defines if the tile is simply part of the world map but moves with it.
Sprite isPlatform - (boolean) * Can other can stand on this sprite.
Sprite isEnclosed - (boolean) * Can other sprites jump through this sprite.
Sprite xSize - (const decimal) * Horizontal Size in pixels
Sprite ySize - (const decimal) * Vertical Size in pixels
Sprite Type - (const decimal) * This may not be used, possibly used to identify weapons/bullets? Unsure
Sprite canJump - (boolean) * Can jump on a platform
Sprite canJumpLeft - (boolean) * Can jump left from a platform
Sprite canJumpRight - (boolean) * Can jump right from a platform
Sprite canFall - (boolean) * Can fall from a platform
Sprite canFallLeft - (boolean) * Can fall from a platform from the left
Sprite canFallRight - (boolean) * Can fall from a platform from the right
Sprite isObstacle - (boolean) * Can other sprites pass or move past this one.
Sprite gravity - (const decimal) * Amount of gravity for jumping / falling sprites

Sprite collisionEnabled - (boolean) * Defines if this sprite can collide with others (linked to hit point)
Sprite defMoveSpeed - (const decimal) * Defines the default move speed of the sprite in the world
Sprite defaultAnimSpeed - (const decimal) * Defines the default frame animation speed

* Below are the sprite types

[Frames Index]

Sprite staticId - (const frameIndex) * Unique Id for Sprite animation type (i.e. walking left/static etc)
Sprite staticFrames - (array decimals) * Array of frames for the sprite when floating or static
Sprite staticMoveSpeed - (const decimal) * Overides default sprite move speed.
Sprite staticAnimSpeed - (const decimal) * Overides default sprite animate speed.

* Sprite Walking Left
Sprite walkLeftId - (const frameIndex) * Unique Id for Sprite animation type (i.e. walking left/static etc)
Sprite walkLeftFrames - (array decimal) * Array of frames for the sprite when walking left
Sprite walkLeftMoveSpeed - (const decimal) * Overides default sprite move speed.
Sprite walkLeftAnimSpeed - (const decimal) * Overides default sprite animate speed.

* Sprite Walking Right
Sprite walkRightFrames - (array decimal)
Sprite walkUpFrames - (array decimal)
Sprite walkDownFrames - (array decimal)
Sprite jumpUpFrames - (array decimal)
Sprite jumpLeftFrames - (array decimal)
Sprite jumpRightFrames - (array decimal)
Sprite fallDownFrames - (array decimal)
Sprite fallLeftFrames - (array decimal)
Sprite fallRightFrames - (array decimal)
Sprite landDownFrames - (array decimal)
Sprite landLeftFrames - (array decimal)
Sprite landRightFrames - (array decimal)
Sprite leftBounceFrames - (array decimal)
Sprite hitRoofFrames - (array decimal)
Sprite fireLeftFrames - (array decimal)
Sprite fireRightFrames - (array decimal)
Sprite fireUpFrames - (array decimal)
Sprite fireRightFrames - (array decimal)
Sprite climbFrames - (array decimal)
Sprite descendFrames - (array decimal)
Sprite faceForwardFrames - (array decimal)
Sprite faceBackwareFrames - (array decimal)
Sprite generateFrames - (array decimal)
Sprite destroyedFrames - (array decimal)
mcgeezer is offline  
 
Page generated in 0.04787 seconds with 11 queries