Best game you made?

Talk about making games.

Re: Best game you made?

Postby lcl » Tue Nov 15, 2011 5:57 am

SuperSonic wrote:So anyways, if James doesn't mind me asking, what's the hardest funtion you've ever had to make? :)

Well, I'm not sure which code was the hardest to make, but here's one.. :D

A function which loads bitmap file and divides it into frames by the value the user has given.
Currently only left to right pictures can be used with this, it's still under work.
Code: Select all
const int B = 0, G = 1, R = 2;
unsigned char TRANSPARENT[3]; //Array for values of transparent color
unsigned char IMG[6][200][200][3]; //Array for animations frames
int iW, iH, lim;

int readBMP(char * filePath, int images)
{
    int header[64], i, j, k, curImg = 0, value;
    FILE * bmp = fopen(filePath, "r+b");
 
    value = (fgetc(bmp) == 'B');
 
    if (value) //Check if the file exist
    {
    fseek(bmp, 0, SEEK_SET);
    for (i = 0; i < 64; i ++) //Get header info
    {
        header[i] = fgetc(bmp);
    }
 
    iW = header[18] + header[19] * 256; //Get width
    iH = header[22] + header[23] * 256; //Get height
    lim = iW/images; //Set lim equal to width / frames


   fseek(bmp, header[10], SEEK_SET); //Move pointer to the start of the actual image data
 
    for(i = iH - 1; i >= 0; i --) //Loop for y
    {
        curImg = 0;
        for(j = 0; j < iW; j ++) //Loop for x
        {
            k ++;
            IMG[curImg][i][k * (k < lim)][B] = fgetc(bmp); //Get b of current pixel
            IMG[curImg][i][k * (k < lim)][G] = fgetc(bmp); //Get g of current pixel
            IMG[curImg][i][k * (k < lim)][R] = fgetc(bmp); //Get r of current pixel
            if (i == 0 && j == 0) //If we are in the top left corner of the image,
                                  //get the transparent color
            {
                TRANSPARENT[R] = IMG[curImg][i][k * (k < lim)][R]; //Set transparent r
                TRANSPARENT[G] = IMG[curImg][i][k * (k < lim)][G]; //Set transparent g
                TRANSPARENT[B] = IMG[curImg][i][k * (k < lim)][B]; //Set transparent b
            }
            if (k == lim){curImg++; k = 0;}
        }
    }
    }
 
    fclose(bmp); //Close the bitmap file
 
    return value;
}

And a function for drawing the frames for making an animation:
Code: Select all
void drawImg(int num, float size)
{
    int i, j;
    unsigned char RR, GG, BB, tR = TRANSPARENT[R], tG = TRANSPARENT[G], tB = TRANSPARENT[B];
 
    for (i = 0; i < iH; i ++)
    {
        for (j = 0; j < lim; j ++)
        {
            RR = IMG[num][i][j][R]; //Copy current pixels r to RR
            GG = IMG[num][i][j][G]; //Copy current pixels g to GG
            BB = IMG[num][i][j][B]; //Copy current pixels b to BB
            if (RR != tR || GG != tG || BB != tB) //If some of the colours doesn't match with
                                                  //the transparent, draw the pixel
            {
                setpen(RR, GG, BB, 0, size);
                putpixel(j*size, i*size);
            }
        }
    }
}

Usage:
(time is global integer variable)
Code: Select all
readBMP("myBMPFile.bmp", 6); //get the animation with 6 horizontal frames
time ++;
if (time >= 2)
{
    img ++;
    if (img == 6){img = 0;}
    erase(0, 0, 0, 1);
    drawImg(img, 1); //draw the current frame. as time variable changes, so changes the img and the frame to be drawn. and so we achieve an effect of animation :D
    time = 0;
}


When I get this function ready, I will publish it here on forums with explanation of using it.
When this is ready, it will be possible to even make games have custom characters that everyone can make and then load them to the game.
It just requires the player actor to be canvas, but that won't be a problem, because canvas willl collide only with the parts of it where something is drawn.
One just has to remember to use erase();

:D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Best game you made?

Postby Game A Gogo » Tue Nov 15, 2011 12:47 pm

Most complicated function I made was an AI system that would fly through space while avoiding getting hit by asteroids. Very CPU intensive though and it's not even completed D:
Code: Select all
const NORMAL=0;
const APPROACH=1;
const ATTACK=2;
const ARREST=3;
const TERMINATE=4;
const ROAMING=5;
const CAPTURE=6;
int GotoAIModule(char* Target,int ClI, int Cond)
{
    //Goto AI Module V1
    //Makes a space craft fly towards a target under certain conditions.
    Actor*Tactor=NULL;
    Actor*T2actor=NULL;
    Actor*Clactor=NULL;
    double tnum,SD=16*directional_velocity+128;
    int i;
    //Big rocks
    if(ClI==-1)Tactor=getclone(Target);
    else Tactor=getclone2(Target,ClI);
    for(i=0;i<128;i++)
    {
        Clactor=getclone2("Aste_B",i);
        if(Clactor->Dead&&distance(x+32,y+32,Clactor->x,Clactor->y)<SD){T2actor=Clactor;SD=distance(x+32,y+32,Clactor->x,Clactor->y);}
    }
    //Med rocks
    for(i=0;i<512;i++)
    {
        Clactor=getclone2("Aste_M",i);
        if(Clactor->Dead&&distance(x+32,y+32,Clactor->x,Clactor->y)<SD){T2actor=Clactor;SD=distance(x+32,y+32,Clactor->x,Clactor->y);}
    }
    //Small rocks
    for(i=0;i<2024;i++)
    {
        Clactor=getclone2("Aste_S",i);
        if(Clactor->Dead&&distance(x+32,y+32,Clactor->x,Clactor->y)<SD){T2actor=Clactor;SD=distance(x+32,y+32,Clactor->x,Clactor->y);}
    }
    if(SD<16*directional_velocity+128)
    {
        tnum=getangle(angle,direction(x,y,T2actor->x,T2actor->y));
        if(abs(tnum)<45&&getangle(SC_Stat[ShipID][0]+90,direction(x,y,T2actor->x,T2actor->y))<45)
        {
            if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
            if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;ðÐ
        }
        if(directional_velocity>5)SC_Con[ShipID][3]=1;
        else SC_Con[ShipID][2]=1;
        return 0;
    }
    else
    {
    if(Tactor)
    {
        if(Cond==NORMAL||Cond==ATTACK)
        {
            if(strcmp(Tactor->name,"SPR_SpaceCraft")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft1")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft2")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft3")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft4")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft5")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft6")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft7")==0)
            {
                if(distance(x,y,Tactor->x,Tactor->y)>130)
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,direction(x,y,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
                    if(distance(x,y,Tactor->x,Tactor->y)>400)
                    {
                        if(directional_velocity<25){SC_Con[ShipID][2]=1;SC_Con[ShipID][6]=1;}
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x,y,Tactor->x,Tactor->y)>200)
                    {
                        if(directional_velocity<17)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x,y,Tactor->x,Tactor->y)>150)
                    {
                        if(directional_velocity<7)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else
                    {
                        if(directional_velocity<4)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    if(directional_velocity>1&&abs(getangle(angle,direction(x,y,Tactor->x,Tactor->y)))>=45)SC_Con[ShipID][3]=1;
                }
                else
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,225+direction(x,y,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;ðÐ
                    if(directional_velocity>5)SC_Con[ShipID][3]=1;
                    else SC_Con[ShipID][2]=1;
                }
            }
            else
            {
                if(distance(x+32,y+32,Tactor->x,Tactor->y)>130)
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,direction(x+32,y+32,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
                    if(distance(x+32,y+32,Tactor->x,Tactor->y)>400)
                    {
                        if(directional_velocity<25){SC_Con[ShipID][2]=1;SC_Con[ShipID][6]=1;}
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>205)
                    {
                        if(directional_velocity<17)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>150)
                    {
                        if(directional_velocity<7)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else
                    {
                        if(directional_velocity<4)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    if(directional_velocity>1&&abs(getangle(angle,direction(x+32,y+32,Tactor->x,Tactor->y)))>=45)SC_Con[ShipID][3]=1;
                }
                else
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,225+direction(x+32,y+32,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;ðÐ
                    if(directional_velocity>5)SC_Con[ShipID][3]=1;
                    else SC_Con[ShipID][2]=1;
                }
            }
        }
        else if(Cond==APPROACH)
        {
            if(strcmp(Tactor->name,"SPR_SpaceCraft")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft1")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft2")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft3")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft4")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft5")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft6")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft7")==0)
            {
                if(distance(x,y,Tactor->x,Tactor->y)>130)
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,direction(x,y,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
                    if(distance(x,y,Tactor->x,Tactor->y)>400)
                    {
                        if(directional_velocity<25){SC_Con[ShipID][2]=1;SC_Con[ShipID][6]=1;}
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x,y,Tactor->x,Tactor->y)>200)
                    {
                        if(directional_velocity<17)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x,y,Tactor->x,Tactor->y)>150)
                    {
                        if(directional_velocity<5)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else
                    {
                        if(directional_velocity<4)SC_Con[ShipID][3]=1;
                    }
                    if(directional_velocity>1&&abs(getangle(angle,direction(x,y,Tactor->x,Tactor->y)))>=45)SC_Con[ShipID][3]=1;
                }
                else SC_Con[ShipID][3]=1;
            }
            else
            {
                if(distance(x+32,y+32,Tactor->x,Tactor->y)>130)
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,direction(x+32,y+32,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
                    if(distance(x+32,y+32,Tactor->x,Tactor->y)>400)
                    {
                        if(directional_velocity<25){SC_Con[ShipID][2]=1;SC_Con[ShipID][6]=1;}
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>200)
                    {
                        if(directional_velocity<17)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>150)
                    {
                        if(directional_velocity<5)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else
                    {
                        if(directional_velocity<4)SC_Con[ShipID][3]=1;
                    }
                    if(directional_velocity>1&&abs(getangle(angle,direction(x+32,y+32,Tactor->x,Tactor->y)))>=45)SC_Con[ShipID][3]=1;
                }
                else SC_Con[ShipID][3]=1;
            }
        }
        if(Cond==ATTACK)
        {
            if(strcmp(Tactor->name,"SPR_SpaceCraft")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft1")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft2")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft3")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft4")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft5")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft6")==0||
               strcmp(Tactor->name,"SPR_SpaceCraft7")==0)
            {
                if(abs(getangle(SC_Stat[ShipID][0]+90,direction(x,y,Tactor->x,Tactor->y)))<=45&&distance(x,y,Tactor->x,Tactor->y)<512)SC_Con[ShipID][4]=1;
            }
            else
            {
                if(abs(getangle(SC_Stat[ShipID][0]+90,direction(x+32,y+32,Tactor->x,Tactor->y)))<=45&&distance(x+32,y+32,Tactor->x,Tactor->y)<512)SC_Con[ShipID][4]=1;
            }
        }
        if(Cond==CAPTURE)
        {
            {
                if(distance(x+32,y+32,Tactor->x,Tactor->y)>130)
                {
                    tnum=getangle(SC_Stat[ShipID][0]+90,direction(x+32,y+32,Tactor->x,Tactor->y));
                    if(tnum>(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][0]=1;
                    if(tnum<-(PI*(float)SC_SS[ShipID][7]/42))SC_Con[ShipID][1]=1;
                    if(distance(x+32,y+32,Tactor->x,Tactor->y)>400)
                    {
                        if(directional_velocity<25){SC_Con[ShipID][2]=1;SC_Con[ShipID][6]=1;}
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>200)
                    {
                        if(directional_velocity<17)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else if(distance(x+32,y+32,Tactor->x,Tactor->y)>150)
                    {
                        if(directional_velocity<5)SC_Con[ShipID][2]=1;
                        else SC_Con[ShipID][3]=1;
                    }
                    else
                    {
                        if(directional_velocity<4)SC_Con[ShipID][2]=1;
                    }
                    if(directional_velocity>1&&abs(getangle(angle,direction(x+32,y+32,Tactor->x,Tactor->y)))>=45)SC_Con[ShipID][3]=1;
                }
                else SC_Con[ShipID][2]=1;
            }
        }
 
        return 0;
 
    }
    else return -1;
    }
}
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Best game you made?

Postby Hblade » Tue Nov 15, 2011 1:33 pm

Gag: how do you not get confused? I noticed when I have a lot of code I tend to get very confused on whats going on, depending on how long I've been working. like, for 3 days almost all day each day, I've been working on a game. I havent gotten confused on it but after the 3rd night, I was getting super confused about the most basic things.

How could you write a script that long without confusing the crap out of yourself? XD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Best game you made?

Postby Game A Gogo » Tue Nov 15, 2011 3:32 pm

I don't really know... but I get such a rush when working with codes like that
All I know is I can easily wrap my head around large concept, and keep them categorized in my head.
Like this code has basically 4 sections to it. The first section is the evade functions that makes the space ship move out of the way of asteroids.
The three other sections are code for the AI controls, depending on what they should do
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Best game you made?

Postby Hblade » Tue Nov 15, 2011 3:43 pm

Ahhhh =)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Best game you made?

Postby lcl » Tue Nov 15, 2011 3:55 pm

Game A Gogo wrote:All I know is I can easily wrap my head around large concept, and keep them categorized in my head.

That's something I should try to learn!
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Best game you made?

Postby Game A Gogo » Tue Nov 15, 2011 4:34 pm

lcl wrote:
Game A Gogo wrote:All I know is I can easily wrap my head around large concept, and keep them categorized in my head.

That's something I should try to learn!


My problem is I can only apply this in my head for code. I can't put it out on paper or use it for school. D:
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Best game you made?

Postby Hblade » Tue Nov 15, 2011 4:37 pm

same o.o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Best game you made?

Postby hunter84 » Tue Nov 15, 2011 5:36 pm

i realized that game a gogo doesnt have a bunny
If two wrongs don't make a right, try three.
Work in progress:
viewtopic.php?f=4&t=12888

Finished work:
Space Adventures- Lost In Space viewtopic.php?f=4&t=12587
User avatar
hunter84
 
Posts: 133
Joined: Thu Nov 10, 2011 12:13 am
Location: Yukon, Canada
Score: 3 Give a positive score

Re: Best game you made?

Postby SuperSonic » Tue Nov 15, 2011 6:13 pm

@Gogo: Wow, you are like a code freak. I can't even comprehend coding something like what you've done :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Best game you made?

Postby JamesLeonardo32 » Tue Nov 15, 2011 7:22 pm

Im a lil late, but the hardest thing i had to program was getting the ground collision on Sarah right (in AXRIA).

It required 3 actors,
-sarah (with all animations)
-sarahX
-sarahX2


sarahX 1-2 were both thin lines. Both 'sarah' and X2 are parent with X1.
X1 inherits almost all events.
X2 is 2 or 3 pixels down from X1. This is used when colliding with the ground, so it changes the animation for sarah. This is because it wouldn't collide properly with X1.

Confused?

Also i am working on a gameboy style game, 'AXRIA pocket edition'. I started work on it yesterday, using similar but simpler programming to AXRIA. It shouldn't take long X)
Attachments
gameboy00.png
gameboy00.png (4.64 KiB) Viewed 2316 times
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Best game you made?

Postby SuperSonic » Tue Nov 15, 2011 7:31 pm

Ooh, very nice. It looks like fun :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Best game you made?

Postby JamesLeonardo32 » Tue Nov 15, 2011 8:28 pm

Um, wow.
Coding sure is... How to put it?...Strange? A unique thing? both?
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Best game you made?

Postby NightOfHorror » Tue Nov 15, 2011 10:29 pm

First off the bunnies are my enemy and I must exterminate them and second off uhh, never mind.
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Best game you made?

Postby JamesLeonardo32 » Tue Nov 15, 2011 10:50 pm

...kay.
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

PreviousNext

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest