So...
This is is something I made mainly to get better at using some of the C commands, but it sort of turned into a game. Laughing You may have seen it in my C/C++ Questions topic (Thanks again for all the help guys).

Its not much now, but what it is is a simple shooter where zombies are approaching from all around you and you must fend them off. Its very simple, you can only turn around in a circle. I turning and firing done so far, and if you can think up a better name, please tell me. Razz Right now, all I have is a target, but I'm currently working on the zombie sprite.

Here's a screenshot:
So it's an FPS game? Sounds like it could be interesting. Stuff like this makes me wish I had a CE...
Wow, really good hand and gun graphics. It looks really cool. Very Happy
Looks like the wolfenstein hand, pretty sweet and seems like it moves at a decent speed so far!
Nice job so far! I too like the animation Smile (I also wouldn't mind taking a look at the code Razz ) Keep up the good work!
Quote:
if you can think up a better name, please tell me. Razz

Has anyone thought of a better name yet?

Currently, I've just been making it faster and working on the sprites. Not much has changed about the program though.
I think Zombies is fine Smile
looks pretty good! Very Happy I also think zombies is a good name. I like how the gun sprite looks for it kind of reminds me of the old Doom games. Anyways, I think this game could be awesome and keep up the good work! Good Idea
So a CE 2d fps... fascinating! I'm really looking forward to see what this evolves into.
/me starts coding
Pieman7373 wrote:
I think Zombies is fine Smile

Ok, I'll keep the name. Smile

Recently, I added the (test) enemy sprite, and now something causes it to not compile right. It doesn't display any errors, but the screen gets super weird and the emulator resets. I'm pretty sure its not something with the new sprite. Can anyone see something that could cause this? Also, please suggest any optimizations you see.


Code:
// Program Name:
// Author(s):
// Description:

/* Keep these headers */
#include <tice.h>

/* Standard headers - it's recommended to leave them included */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Other available headers */
// including stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h
#include <sprites.h>
/* Available libraries */
// including lib/ce/graphc.h, lib/ce/fileioc.h, and lib/ce/keypadc.h
// Sample: #include <lib/ce/graphc.h>
#include <lib/ce/graphx.h>
#include <lib/ce/keypadc.h>

/* Put your function prototypes here */
int move_zombie(int distance);
void zombie_dead(void);
bool shoot_gun(void);
void reload(void);
void update(void);
void CheckRange(void);
/* Put all your globals here. */
typedef struct zombie{
    int distance;
    int health;
    int x;
    bool WithinRange;
} zombie;

typedef struct player{
    int ammo;
    int health;
    int x;
}player;
/* Put all your code here */
player Player;
zombie Zombie;

void main() {
   // Main program code goes here
    int kTurn=0, kShoot=0, kReload=0;
    int ShowFiring=0, CanShoot=0;
    Player.ammo=10;
    Player.health=10;
    Player.x=0;
    Zombie.x=0;
    gfx_Begin(gfx_8bpp);
    gfx_SetDrawBuffer();
    gfx_SetColor(255);
    gfx_SetPalette( sprites_pal, sizeof(sprites_pal), 0);
    gfx_FillScreen(255);
    CheckRange();
    gfx_TransparentSprite(EnemySprite,Zombie.x,100);
    gfx_TransparentSprite(SilencedPistol,75,144);
    update();
    gfx_BlitBuffer();
    while(kb_ScanGroup(kb_group_6) != kb_Clear){
        if (kTurn & kb_Left){
            if (Player.x!=0){
                Player.x--;
            }else{
                Player.x=360;
            }
            gfx_FillRectangle(Zombie.x,100,150,140);
            Zombie.x+=3;
            gfx_TransparentSprite(EnemySprite,Zombie.x,100);
            gfx_BlitBuffer();
            update();
        }
        if (kTurn & kb_Right){
            if (Player.x!=360){
                Player.x++;
            }else{
                Player.x=0;
            }
            gfx_FillRectangle(Zombie.x,100,150,140);
            Zombie.x-=3;
            gfx_TransparentSprite(EnemySprite,Zombie.x,100);
            gfx_BlitBuffer();
            update();
        }
        if (kReload & kb_Alpha){
            reload();
            update();
        }
        if ((kShoot & kb_2nd) && (!ShowFiring && !CanShoot)){
            ShowFiring=10;
            if (shoot_gun()){
                zombie_dead();
            }
            update();
        }
        if (ShowFiring){
            if (Zombie.WithinRange){
                gfx_TransparentSprite(SilencedPistolFiring,75,140);
                gfx_BlitBuffer();
            }
            ShowFiring--;
            if (!ShowFiring){
                gfx_FillRectangle(75,140,114,100);
                gfx_TransparentSprite(SilencedPistol,75,142);
                gfx_BlitBuffer();
                gfx_FillRectangle(75,142,114,100);
                gfx_TransparentSprite(SilencedPistol,75,144);
                gfx_BlitBuffer();
                gfx_TransparentSprite(EnemySprite,Zombie.x,100);
                gfx_BlitBuffer();
                CanShoot=10;
            }
        }
        if (CanShoot){
            CanShoot--;
        }
        kShoot=kb_ScanGroup(kb_group_1);
        kTurn=kb_ScanGroup(kb_group_7);
        kReload=kb_ScanGroup(kb_group_2);
    }
    gfx_End();
    pgrm_CleanUp();
}

/* Other functions */
int move_zombie(int distance){
    distance-=1;
    return distance;
}

bool shoot_gun(void){
    bool hit;
    if(Player.ammo){
        Player.ammo--;
        //gun moving upward
        gfx_FillRectangle(75,144,114,100);
        gfx_TransparentSprite(SilencedPistol,75,142);
        gfx_BlitBuffer();
        gfx_FillRectangle(75,142,114,100);
        gfx_TransparentSprite(SilencedPistolFiring,75,140);
        gfx_BlitBuffer();
        gfx_TransparentSprite(EnemySprite,Zombie.x,100);
        gfx_BlitBuffer();
        if(Player.x==Zombie.x){
            hit=true;
        }else{
            hit=false;
        }
        return hit;
    }else{
        reload();
        hit=false;
        return hit;
    }
}
void reload(void){
    //show reloading animation
    Player.ammo=10;
    return;
}

void zombie_dead(void){
    //zombie die
    gfx_PrintStringXY("hit",100,100);
}

void update(void){
    gfx_FillRectangle(0,0,30,20);
    gfx_SetTextXY(0,0);
    gfx_PrintInt(Player.x,3);
    gfx_SetTextXY(0,9);
    gfx_PrintInt(Player.ammo,2);
}

void CheckRange(void){
    if (Zombie.x+150>=Player.x && Zombie.x<=Player.x){
        Zombie.WithinRange=true;
    }else{
        Zombie.WithinRange=false;
    }
}
So, as it turns out, my problem was that my sprites were too big. Razz I made them a (lot) smaller, deleted a bunch of empty space that I should of gotten rid of in the first place.

I also was having trouble on my own zombie sprite, so I'm just going to use a monster from Doom. I don't have any screenshots yet, I'm still rewriting a lot of code, but I'll have some soon.

EDIT: I added in all the sprites. I still need to edit the new Doom sprite, but other than that, I'm done with sprites for now.
Looks great! Do you think you could add a black hole where we shot the zombie? Just to be sure we actually killed it. Smile
Thanks! Yeah, I made a sprite for that. Smile I just haven't implemented it yet.
Looking pretty spiffy for sure! Keep up the good work Smile
Cool cool, very in your face with the size of the sprite ... sure to produce a few scares Smile.
If I'm right, you use 2 buffers and 'switch' between them using gfx_Blit or so, but it might be a lot faster if you replace that with gfx_SwapDraw or something like that Wink
I added some more functions, and something went wrong (as always). Sad I'm hoping more sets of eyes will help. It compiles, but it freezes when I run it. Here's the code.

Code:
// Program Name:
// Author(s):
// Description:

/* Keep these headers */
#include <tice.h>

/* Standard headers - it's recommended to leave them included */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Other available headers */
// including stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h
#include <sprites.h>
#include <xlibcsprites.h>
/* Available libraries */
// including lib/ce/graphc.h, lib/ce/fileioc.h, and lib/ce/keypadc.h
// Sample: #include <lib/ce/graphc.h>
#include <lib/ce/graphx.h>
#include <lib/ce/keypadc.h>

/* Put your function prototypes here */
void zombie_dead(void);
bool shoot_gun(void);
void update(void);
void CheckRange(void);
void AddBloodSplatter(void);
/* Put all your globals here. */
typedef struct zombie{
    int distance;
    int health;
    int x;
    bool WithinScreen;
    bool WithinGun;
    bool GunRedraw;
    int ShowBloodSplatter[2];
} zombie;

typedef struct player{
    int ammo;
    int health;
}player;
/* Put all your code here */
player Player;
zombie Zombie;

void main() {
   // Main program code goes here
    int kTurn=0, kShoot=0;
    int ShowFiring=0, CanShoot=0, x;
    Player.ammo=10;
    Player.health=10;
    Zombie.x=0;
    Zombie.health=100;
    Zombie.ShowBloodSplatter[0]=0;
    Zombie.ShowBloodSplatter[1]=0;
    gfx_Begin(gfx_8bpp);
    gfx_SetDrawBuffer();
    gfx_SetColor(255);
    gfx_FillScreen(255);
    gfx_SetPalette(sprites_pal,sizeof(sprites_pal),0);
    CheckRange();
    gfx_TransparentSprite(EnemySprite,Zombie.x,30);
    for(x=0;x<2;--x){
        if (Zombie.ShowBloodSplatter[x]){
            gfx_TransparentSprite(BloodSplatter,Zombie.ShowBloodSplatter[x]+Zombie.x,100);
        }
    }
    gfx_SetPalette(xlibcsprites_pal,sizeof(xlibcsprites_pal),0);
    gfx_TransparentSprite(SilencedPistol,131,174);
    update();
    gfx_BlitBuffer();
    while(kb_ScanGroup(kb_group_6) != kb_Clear){
        if (kTurn & kb_Left){
            CheckRange();
            if (ShowFiring)
                --ShowFiring;
            if (CanShoot)
                --CanShoot;
            if (Zombie.WithinScreen){
                gfx_FillRectangle(Zombie.x,30,225,210);
            }
            if (Zombie.x>=750){
                Zombie.x=-625;
            }else{
                Zombie.x+=8;
            }
            if (Zombie.WithinScreen){
                gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                if (Zombie.WithinGun){
                    if (ShowFiring){
                        gfx_TransparentSprite(SilencedPistolFiring,131,154);
                    }else{
                        gfx_TransparentSprite(SilencedPistol,131,174);
                    }
                }
                for(x=0;x<2;--x){
                    if (Zombie.ShowBloodSplatter[x]){
                        gfx_TransparentSprite(BloodSplatter,Zombie.ShowBloodSplatter[x]+Zombie.x,100);
                    }
                }
                gfx_BlitBuffer();
            }
            update();
        }
        if (kTurn & kb_Right){
            CheckRange();
            if (ShowFiring)
                --ShowFiring;
            if (CanShoot)
                --CanShoot;
            if (Zombie.WithinScreen){
                gfx_FillRectangle(Zombie.x,30,225,210);
            }
            if (Zombie.x<=-625){
                Zombie.x=750;
            }else{
                Zombie.x-=8;
            }
            if (Zombie.WithinScreen){
                gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                if (Zombie.WithinGun){
                    if (ShowFiring){
                        gfx_TransparentSprite(SilencedPistolFiring,131,154);
                    }else{
                        gfx_TransparentSprite(SilencedPistol,131,174);
                    }
                }
                for(x=0;x<2;--x){
                    if (Zombie.ShowBloodSplatter[x]){
                        gfx_TransparentSprite(BloodSplatter,Zombie.ShowBloodSplatter[x]+Zombie.x,100);
                    }
                }
                gfx_BlitBuffer();
            }
            update();
        }
        if ((kShoot & kb_2nd) && (!ShowFiring && !CanShoot)){
            ShowFiring=10;
            if (shoot_gun()){
                AddBloodSplatter();
                Zombie.health-=50;
                if (!Zombie.health)
                    zombie_dead();
            }
            update();
        }
        if (ShowFiring){
            gfx_TransparentSprite(SilencedPistolFiring,131,154);
            gfx_BlitBuffer();
            --ShowFiring;
            if (!ShowFiring){
                if (Zombie.WithinGun){
                    gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                }else{
                    for(x=0;x<50;x++)
                        gfx_FillRectangle(131,154,57,86);
                }
                gfx_TransparentSprite(SilencedPistol,131,172);
                gfx_BlitBuffer();
                if (Zombie.WithinGun){
                    gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                }else{
                    for(x=0;x<50;x++)
                        gfx_FillRectangle(131,172,57,70);
                }
                gfx_TransparentSprite(SilencedPistol,131,174);
                gfx_BlitBuffer();
                CanShoot=10;
            }
        }
        if (CanShoot){
            --CanShoot;
        }
        CheckRange();
        kShoot=kb_ScanGroup(kb_group_1);
        kTurn=kb_ScanGroup(kb_group_7);
    }
    gfx_End();
    pgrm_CleanUp();
}

/* Other functions */

bool shoot_gun(void){
    bool hit;
    int x;
    if(Player.ammo){
        --Player.ammo;
        //gun moving upward
        if (Zombie.WithinGun){
            gfx_TransparentSprite(EnemySprite,Zombie.x,30);
        }else{
            for(x=0;x<50;x++)
                gfx_FillRectangle(131,174,57,70);
        }
        gfx_TransparentSprite(SilencedPistol,131,172);
        gfx_BlitBuffer();
        if (Zombie.WithinGun){
            gfx_TransparentSprite(EnemySprite,Zombie.x,30);
        }else{
            for(x=0;x<50;x++)
                gfx_FillRectangle(131,172,57,70);
        }
        gfx_TransparentSprite(SilencedPistolFiring,131,154);
        gfx_BlitBuffer();
        if(Zombie.x+50<=158 && Zombie.x+175>=162){
            hit=true;
        }else{
            hit=false;
        }
        return hit;
    }else{
        hit=false;
        return hit;
    }
}

void zombie_dead(void){
    gfx_PrintStringXY("Kill!",150,0);
    gfx_FillRectangle(Zombie.x,30,225,210);
    gfx_BlitBuffer();
}

void update(void){
    gfx_FillRectangle(0,0,30,20);
    gfx_SetTextXY(0,0);
    gfx_PrintInt(Zombie.x,3);
    gfx_SetTextXY(0,9);
    gfx_PrintInt(Player.ammo,2);
}

void CheckRange(void){
    if (Zombie.x+225>=0 && Zombie.x<=360){
        Zombie.WithinScreen=true;
    }else{
        Zombie.WithinScreen=false;
    }
    if (Zombie.x+225>=188 && Zombie.x<=131){
        Zombie.WithinGun=true;
    }else{
        Zombie.WithinGun=false;
    }
}

void AddBloodSplatter(void){
        if (!Zombie.ShowBloodSplatter[0]){
            Zombie.ShowBloodSplatter[0]=160-Zombie.x+50;
        }else{
            Zombie.ShowBloodSplatter[1]=160-Zombie.x+50;
        }
}
Recently, I've been cleaning my code up. This means I'm using local variables and wow - multiple files (Never done that before Laughing. It feels really wierd not using global variables for everything.). I've also added all my code to github so that users can review it. Hopefully people can correct my code Razz.

https://github.com/Calcnerd/Zombies-TI-84-CE-

I also still have a bug where the calculator resets if I try to turn. Sad
Eeep
Sorry, Calcnerd Razz
I forgot i was supposed to me making stuff for you... i started, but havent finished
That reminds me... I owe people like 300 different programs...

Aww screw it..

That code is very pretty, very neat, very long, very awesome, and very confusing... (I should really learn C)

Seems like very good code, if you ask me.
Guess who rendered a 3D cube in 5 min in BASIC on his CE last night... shhh It's a secret...Amazing job!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement