Skip to content

Commit

Permalink
Add new object
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Cho committed Dec 29, 2023
1 parent e8a7be8 commit 455fc09
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
18 changes: 8 additions & 10 deletions Space Bandits/Space Bandits.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
52F845272442911300B1D70F /* DSLevelFileParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 52F845252442911300B1D70F /* DSLevelFileParser.m */; };
7D3110E922FF018D00833374 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D3110E822FF018D00833374 /* SDL2.framework */; };
7D3110EE22FF01D700833374 /* DSCoCoJoystick.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7D3110ED22FF01D700833374 /* DSCoCoJoystick.mm */; };
7D45E1422B3F48A9005E6F4B /* 12-shipx.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D45E1402B3F48A8005E6F4B /* 12-shipx.c */; };
7D5BE99528FC447E00544DFF /* 10-fixed_object.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D5BE99328FC447E00544DFF /* 10-fixed_object.c */; };
7D5BE99828FC490600544DFF /* 11-velocity_object.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D5BE99628FC490600544DFF /* 11-velocity_object.c */; };
7D5BE99A28FC4F1B00544DFF /* universal_object.h in Sources */ = {isa = PBXBuildFile; fileRef = 7D5BE99928FC4CBC00544DFF /* universal_object.h */; };
Expand All @@ -200,8 +201,6 @@
7DA178BB2431552E00AE39D8 /* 05-missile.c in Sources */ = {isa = PBXBuildFile; fileRef = 7DA178B32431552D00AE39D8 /* 05-missile.c */; };
7DA178BC2431552E00AE39D8 /* 06-gameover.c in Sources */ = {isa = PBXBuildFile; fileRef = 7DA178B72431552E00AE39D8 /* 06-gameover.c */; };
7DA178BF243155A900AE39D8 /* 01-persei.c in Sources */ = {isa = PBXBuildFile; fileRef = 7DA178BE243155A900AE39D8 /* 01-persei.c */; };
7DC1E70A29F4658000E620ED /* 12-ship.c in Sources */ = {isa = PBXBuildFile; fileRef = 7DC1E70929F4658000E620ED /* 12-ship.c */; };
7DC1E70B29F4658000E620ED /* 12-ship.c in Sources */ = {isa = PBXBuildFile; fileRef = 7DC1E70929F4658000E620ED /* 12-ship.c */; };
7DC4E7EF22FFB94000AE8AB4 /* DSCoCoKeyboardJoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC4E7EE22FFB94000AE8AB4 /* DSCoCoKeyboardJoystick.m */; };
7DC4E7F422FFC33A00AE8AB4 /* DSCoCoJoystickController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC4E7F322FFC33A00AE8AB4 /* DSCoCoJoystickController.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -408,6 +407,8 @@
7D3110E822FF018D00833374 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SDL2.framework; sourceTree = "<group>"; };
7D3110EC22FF01D700833374 /* DSCoCoJoystick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSCoCoJoystick.h; sourceTree = "<group>"; };
7D3110ED22FF01D700833374 /* DSCoCoJoystick.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DSCoCoJoystick.mm; sourceTree = "<group>"; };
7D45E1402B3F48A8005E6F4B /* 12-shipx.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = "12-shipx.c"; path = "../../game/objects/12-shipx.c"; sourceTree = "<group>"; };
7D45E1412B3F48A9005E6F4B /* 12-shipx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "12-shipx.h"; path = "../../game/objects/12-shipx.h"; sourceTree = "<group>"; };
7D5BE99328FC447E00544DFF /* 10-fixed_object.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = "10-fixed_object.c"; path = "../../game/objects/10-fixed_object.c"; sourceTree = "<group>"; };
7D5BE99428FC447E00544DFF /* 10-fixed_object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "10-fixed_object.h"; path = "../../game/objects/10-fixed_object.h"; sourceTree = "<group>"; };
7D5BE99628FC490600544DFF /* 11-velocity_object.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = "11-velocity_object.c"; path = "../../game/objects/11-velocity_object.c"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -439,8 +440,6 @@
7DA178B62431552D00AE39D8 /* 06-gameover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "06-gameover.h"; path = "../../game/objects/06-gameover.h"; sourceTree = "<group>"; };
7DA178B72431552E00AE39D8 /* 06-gameover.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = "06-gameover.c"; path = "../../game/objects/06-gameover.c"; sourceTree = "<group>"; };
7DA178BE243155A900AE39D8 /* 01-persei.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = "01-persei.c"; path = "../../game/levels/01-persei.c"; sourceTree = "<group>"; };
7DC1E70929F4658000E620ED /* 12-ship.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; name = "12-ship.c"; path = "../../game/objects/12-ship.c"; sourceTree = "<group>"; };
7DC1E70C29F4735200E620ED /* 12-ship.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "12-ship.h"; sourceTree = "<group>"; };
7DC4E7E822FFB79A00AE8AB4 /* DSCoCoJoystickProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSCoCoJoystickProtocol.h; sourceTree = "<group>"; };
7DC4E7ED22FFB94000AE8AB4 /* DSCoCoKeyboardJoystick.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSCoCoKeyboardJoystick.h; sourceTree = "<group>"; };
7DC4E7EE22FFB94000AE8AB4 /* DSCoCoKeyboardJoystick.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSCoCoKeyboardJoystick.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -739,6 +738,8 @@
7DA178AC2431551D00AE39D8 /* objects */ = {
isa = PBXGroup;
children = (
7D5BE99928FC4CBC00544DFF /* universal_object.h */,
7D5BE99B28FC4FAC00544DFF /* universal_object.c */,
7DA178B02431552D00AE39D8 /* object_info.h */,
523A6C5425DC1AA700C609B4 /* 01-numerals.h */,
523A6C5125DC198F00C609B4 /* 01-numerals.mm */,
Expand All @@ -760,10 +761,8 @@
7D5BE99328FC447E00544DFF /* 10-fixed_object.c */,
7D5BE99728FC490600544DFF /* 11-velocity_object.h */,
7D5BE99628FC490600544DFF /* 11-velocity_object.c */,
7D5BE99928FC4CBC00544DFF /* universal_object.h */,
7D5BE99B28FC4FAC00544DFF /* universal_object.c */,
7DC1E70C29F4735200E620ED /* 12-ship.h */,
7DC1E70929F4658000E620ED /* 12-ship.c */,
7D45E1402B3F48A8005E6F4B /* 12-shipx.c */,
7D45E1412B3F48A9005E6F4B /* 12-shipx.h */,
);
name = objects;
sourceTree = "<group>";
Expand Down Expand Up @@ -1011,7 +1010,6 @@
52B1A129244B8667008E7066 /* DSLevelFileParserTest.m in Sources */,
529201F0244150C1000B4D58 /* DSSoundManagerTest.m in Sources */,
521A84B321FE07A8006120E8 /* DSSceneControllerTest.m in Sources */,
7DC1E70B29F4658000E620ED /* 12-ship.c in Sources */,
52B1A166244D2213008E7066 /* DSTileInfoTest.m in Sources */,
529201F42441A63F000B4D58 /* DSResourceControllerTest.m in Sources */,
5279A4E72436B83B00A51D98 /* DSCoCoJoystickControllerTest.m in Sources */,
Expand All @@ -1038,7 +1036,6 @@
52E447002464DCDC008B6488 /* DSScene.m in Sources */,
527E7ACD21F016B90013E66A /* DSInitScene.m in Sources */,
7D5BE99528FC447E00544DFF /* 10-fixed_object.c in Sources */,
7DC1E70A29F4658000E620ED /* 12-ship.c in Sources */,
7DA178BB2431552E00AE39D8 /* 05-missile.c in Sources */,
52B1A159244CFE45008E7066 /* DSPoint.c in Sources */,
524402DF21ED65CF00B02D38 /* DSTransitionScene.m in Sources */,
Expand Down Expand Up @@ -1090,6 +1087,7 @@
52F1208921D7DD63008A7900 /* DSAppDelegate.m in Sources */,
52B1A13B244BD4F9008E7066 /* DSSpriteObjectClass.m in Sources */,
52796B27259E7EA900FF17B6 /* DSTexture.m in Sources */,
7D45E1422B3F48A9005E6F4B /* 12-shipx.c in Sources */,
52E9623F28E8B53F0086065F /* DSDefaultsConfigLoader.m in Sources */,
7DA178B82431552E00AE39D8 /* 03-badguy.c in Sources */,
7DA178BA2431552E00AE39D8 /* 07-badmissile.c in Sources */,
Expand Down
12 changes: 6 additions & 6 deletions game/levels/02-space.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ extern "C" {

#include <coco.h>
#include "dynosprite.h"
#include "universal_object.h"
#include "../objects/universal_object.h"
#include "../objects/object_info.h"


void SpaceInit() {
GameGlobals *globals = (GameGlobals *)DynospriteGlobalsPtr;
globals->gameState = GameStateOver;
Expand All @@ -20,9 +20,9 @@ byte SpaceCalculateBkgrndNewXY() {
DynospriteCOB *obj = DynospriteDirectPageGlobalsPtr->Obj_CurrentTablePtr;
DynospriteCOB *lastObj = obj + DynospriteDirectPageGlobalsPtr->Obj_NumCurrent;
byte xoffset = DynospriteDirectPageGlobalsPtr->Gfx_BkgrndNewX + 160;
byte yoffset = DynospriteDirectPageGlobalsPtr->Gfx_BkgrndNewY;
byte yoffset = DynospriteDirectPageGlobalsPtr->Gfx_BkgrndNewY;
for(; obj<lastObj; obj++) {
if (obj->active & OBJECT_ACTIVE == 0) {
if ((obj->active & OBJECT_ACTIVE) == 0) {
continue;
}

Expand All @@ -35,8 +35,8 @@ byte SpaceCalculateBkgrndNewXY() {
depth = 2;
uobj->position[0] = (2 * uobj->position[0] - (xoffset << depth)) >> depth;
}


return 0;
}

Expand Down
6 changes: 2 additions & 4 deletions game/levels/02-space.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"InitData": []
},


{
"_comment": "***** Score",
"GroupID": 1,
Expand All @@ -34,7 +33,6 @@
"InitData": []
},


{
"_comment": "***** ShipCounter1",
"GroupID": 8,
Expand Down Expand Up @@ -71,7 +69,7 @@
"globalY": 4,
"InitData": [4]
},

{
"_comment": "***** Fixed Object",
"GroupID": 10,
Expand All @@ -81,7 +79,7 @@
"globalY": 100,
"InitData": [0, 1, 0, 18, 0, 13, 0, 160, 0, 100]
},

{
"_comment": "***** Velocity Object",
"GroupID": 11,
Expand Down
4 changes: 2 additions & 2 deletions game/objects/10-fixed_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "universal_object.h"

/** Defines at least the size of Fixedobject_State in bytes */
#define DynospriteObject_DataSize 16
#define DynospriteObject_DataSize 12

/** Defines at least the number of initialization bytes */
#define DynospriteObject_InitSize 12
#define DynospriteObject_InitSize 10

#else

Expand Down
2 changes: 1 addition & 1 deletion game/objects/11-velocity_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/** State of Velocity Object */
typedef struct Velocity_objectObjectState {
UniversalObject *obj;
UniversalObject obj;
} Velocity_objectObjectState;


Expand Down
14 changes: 7 additions & 7 deletions game/objects/12-ship.c → game/objects/12-shipx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// 12-ship.c
// 12-shipx.c
// Space Bandits
//
// Created by Jamie Cho on 4/22/23.
Expand All @@ -13,35 +13,35 @@
// version of Space Bandits, this file must be included directly by
// objects that use it.

#include "12-ship.h"
#include "12-shipx.h"
#include "../objects/object_info.h"


static GameGlobals *globals;


#ifdef __APPLE__
void Ship12ClassInit() {
void ShipxClassInit() {
globals = NULL;
}
#endif


void Ship12Init(DynospriteCOB *cob, DynospriteODT *odt, byte *initData) {
void ShipxInit(DynospriteCOB *cob, DynospriteODT *odt, byte *initData) {
if (!globals) {
}
}


byte Ship12Reactivate(DynospriteCOB *cob, DynospriteODT *odt) {
byte ShipxReactivate(DynospriteCOB *cob, DynospriteODT *odt) {
return 0;
}


byte Ship12Update(DynospriteCOB *cob, DynospriteODT *odt) {
byte ShipxUpdate(DynospriteCOB *cob, DynospriteODT *odt) {
return 0;
}


RegisterObject(Ship12ClassInit, Ship12Init, 0, Ship12Reactivate, Ship12Update, NULL, sizeof(Ship12ObjectState));
RegisterObject(ShipxClassInit, ShipxInit, 0, ShipxReactivate, ShipxUpdate, NULL, sizeof(ShipxObjectState));

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// 12-ship.h
// 12-shipx.h
// Space Bandits
//
// Created by Jamie Cho on 2/18/21.
Expand All @@ -11,24 +11,24 @@
#ifdef DynospriteObject_DataDefinition

/** Defines at least the size of ShipCounterObjectState in bytes */
#define DynospriteObject_DataSize 14
#define DynospriteObject_DataSize 16

/** Defines at least the number of initialization bytes */
#define DynospriteObject_InitSize 14

#else

#ifndef _12_ship_h
#define _12_ship_h
#ifndef _12_shipx_h
#define _12_shipx_h

#include "dynosprite.h"


/** State of Ship Object */
typedef struct Ship12ObjectState {
} Ship12CounterObjectState;
typedef struct ShipxObjectState {
} ShipxCounterObjectState;


#endif /* _12_ship_h */
#endif /* _12_shipx_h */

#endif /* DynospriteObject_DataDefinition */
10 changes: 7 additions & 3 deletions game/objects/universal_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ typedef sbyte BoundingBox[4];
typedef struct UniversalObject {
/** Index of current sprite to show */
byte spriteIdx;

/** Magic numbers */
word magicNumber;

/** Depth of object - 1 is closest to user, 4 is deepest depth. */
byte depth;

/** bounding box to use for intersections */
BoundingBox boundingBox;

Expand All @@ -45,10 +45,14 @@ typedef struct UniversalObject {
Vector velocity;
} UniversalObject;

MAYBE_UNUSED
static void UniversalObjectFixedObjectInit(DynospriteCOB *cob, DynospriteODT *odt, byte *initData);
MAYBE_UNUSED
static void UniversalObjectFixedObjectClip(DynospriteCOB *cob, DynospriteODT *odt);

MAYBE_UNUSED
static void UniversalObjectVelocityObjectInit(DynospriteCOB *cob, DynospriteODT *odt, byte *initData);
MAYBE_UNUSED
static void UniversalObjectVelocityObjectUpdate(DynospriteCOB *cob, DynospriteODT *odt);

#endif /* DynospriteObject_DataDefinition */
Expand Down
15 changes: 15 additions & 0 deletions game/sprites/12-shipx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Main": {
"Group": 12,
"Image": "marbles.png",
"Transparent": [128, 128, 128],
"Palette": 1
},

"Sprites": [{
"Name": "Cycle_2",
"Location": [54, 39],
"SinglePixelPosition": true
}]
}

0 comments on commit 455fc09

Please sign in to comment.