This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-12-29 02:19:39

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Code for a game

http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs790.ash1/168023_152198668165319_100001255614457_301278_4860522_n.jpg
ACTUAL GAME TITLE SCREEN SCREENSHOT!



I am working on a c++ game with the name HALO v/s CounterStrike

. wanted to see if someone is intrested in making a scratch version of it cuz its all C++

Because the code is easy to understand and i think a lot of intrested scratchers can make this.
So far the C++ Version has ::
1. Team based gameplay
2. Flag taking Maps // Thats u win by capturing the flag
3. Combat Maps // That is u win by killing most peoples u can .
4. AI . a crispy and very intelligent AI which can climb on ladders , Jump to cross a void
   make a choice of saving the flag / objective or to shoot at the enemy. And also knows when to run and when to fight.
5. Fast Gameplay.

The game should be out soon  smile 
But i want someone from scratch to make a Scratch Based Online Version of it with or without the full features. So i am embedding coding of C++ game without the AI function because its too huge !! i will post it in a separate post if somebody shows intrest init

Btw i think a list of those who should give this a try

Rhy
Paddle2See 
Jack08
Pinochio
ChaoticD
PlaywithFire
CheddarGirl (well her version will be beautifully done with graphics if she starts)
JSO
Illusionist
FG123

Not me cuz i am not a scratch coder anymore xD

But well the doors are open my C++ version will be out soon and also this code will be updated very frequently aswell .
So lets see if somebody takes the challenge  big_smile 

Heres the code so far :: (NOT THE UPADATES AND AI LOOPS as its huge)

Code:

//**************************************************************************************
//DG Games -> HALO v/s Counter Strike V1
//**************************************************************************************
//Programmer : Abhishek Hingnikar (Dark¥)
//Date:: 28th December 2010
//Uses DarkGDK by Microsoft and The Game Creators
//(c)2010 - DG games - All rights Reserved
//All code is understandable if you are human x)

#include "DarkGDK.h"
// To make camera
float CamX = 0 ;
float CamY = 0 ;
// This functions will interconvert Computer Coordinates to the Cartesian Coordinates
inline float Conv2CartX(float X)
{ return X-512;
}

inline float Conv2CartY(float Y)
{ return 383-Y;
}

inline float Conv2CompX(float X)
{    return X +512;
}
inline float Conv2CompY(float Y)
{    return 383 - Y;
}
//Waypoints of Map and Code

struct Waypoint{
int LevelOne;// Initial Level 
int LevelTwo;// Final Level
int Xpos;
int Ypos;
char Type[4];// Type= J - Jump , S - StairCase;
int Link[4];// Index of waypoint Linked to it 
int UsedLinks;//To tell how many Links outa 4 has been used
};

Waypoint MapPoints[100];
int No_of_MapPoints=0;//No of mappoints using in the map so that we dont go on cheaching for all the points

// NO LETS MAKE SOME GROUND WHERE WE CAN STAND //

class ground{
int X;// Center Coordinates in cartesian
int Y;// Center Coordinates in catresian system

float C; // The line constant .. that is the Y coordinate at X = 0 u can find this by mathematica
float slope; // thats the angle that line makes wiv X axis;
float Length ; // length of the sprite In pixels;

int ImageID;
int SpriteID;

public:
    // I space is a function that returns 1 if the point is touching ground or is on ground else returns 0;

    inline    int Ispace(float h,float k)
    { if(abs(h-X)<=(Length*cos(slope)/2))
        { if(abs(k-(h*tan(slope)+C))<10)
            { return 1;
            }
        }
      return 0;
    }

    //Update is function to print the whole thing on screen
    inline void update()
    { dbSprite(SpriteID,Conv2CompX(X-CamX),Conv2CompY(Y-CamY),ImageID);

    }

    // Load() this should be called to Load Map block as its relaiable (XD)
void    Load()
    {
        dbRotateSprite(SpriteID,slope);
    }
};


//Now we have got a Template "Sprite" and we can now make tons of sprites of Map from it
//but we keeping in rather safe haha. So just Sprite IDs , 4 - 104, are assigned . to map blocks with the image IDs aswell
ground Map[100];// This is map sprites
int No_of_Ground=0;//This will tell now many sprites are in use so we only refresh them

//Now Lets Come to Basic Programming Mehtadologies :D
//Our first basic class which looks like a wargame rathern then  a ground survilliance system
// Ladies and gentle man I present to you the Class Called weapon XD

class Weapon{
float Velocity,Angle,X,Y,Dmi,Range;
int MyID,ImageID,Ammo,Clips,Capacity,Iowner,SoundReloadID,SoundFireID;
public:
void fire(int,int,float);//Declared at the end
void threw();
void Pickup(int);
void reload()
{if(Clips>0)
    {    Ammo += Capacity;
        Clips--;
    }
}

int isrealoading()
{ return dbSoundPlaying(SoundReloadID);
}

int isfiring()
{ return dbSoundPlaying(SoundFireID);
}
};

Weapon Guns[52];

class charac{
public:
    float X;
    float Y;
    float Health;
    int Weapons[2];
    int chosen;
    int SpriteIdUp;
    int SpriteIdDown;
    float dir;
    int ColiX;
    int ColiY;
    char Team; // C - CounterStrike , H - Halo
    void Damage(float DMI)
    { Health -= DMI;
    }

    int ispace(int h,int k)
    { if(abs(h-X)<(ColiX/2)&&abs(k-Y)<(ColiY/2))
        { return 1;
        }
    else
        { return 0;
        }
    }

    // Functions for BOT and HUMAN are different but only for input
    // Humans take input by the Human() function
    // Bots Use AI() and War() and Movement() functions for input.

    float damageindex(int);
    void Update()
    {

    }
};

charac Players[16];//The players in game where 0 is the base player
int No_of_Players;

void Weapon::fire(int Xpos,int Ypos,float dir) 
{    float VelX= Velocity*cos(dir);
    float VelY = Velocity*sin(dir);
    int i = 1;
    while( i*Velocity < Range)
    {for(int k =0;k<No_of_Players;k++)
        { if(Players[k].ispace((Xpos+(VelX*i)),(Ypos+(VelY*i))))
                { Players[k].Damage(Dmi);
                  return;
                }
        }
      for(int k = 0; k < No_of_Ground;k++)
        { if(Map[k].Ispace((Xpos+(VelX*i)),(Xpos+(VelX*i))))
            { return;
            }
        }
      i++;

    }
    return;
}


void Weapon::threw()
{ Players[Iowner].Weapons[Players[Iowner].chosen] = -1;
  X = Players[Iowner].X + 30;
  Y = Players[Iowner].Y - 30;
  Iowner = -1;
}

void Weapon::Pickup(int ByMe)
{ Iowner = ByMe;
Guns[Players[Iowner].Weapons[Players[Iowner].chosen]].threw();
Players[Iowner].Weapons[Players[Iowner].chosen] = MyID;
}
// the main entry point for the application is this function
void DarkGDK ( void )
{    dbSyncOn   ( );
    dbSetDisplayMode ( 1024 , 768 , 32 );
    dbSetWindowOff();
    dbSyncRate ( 60 );
    dbDisableEscapeKey ( );
    dbLoadImage("back.PNG",1);
    // Map INITIALISATION!

    while ( LoopGDK ( ) )
    {      for(int i=0;i<No_of_Players;i++)
        { Players[i].Update();
        }
        for(int i=0;i<No_of_Ground;i++)
        { Map[i].update();
        }
        if ( dbEscapeKey ( ) )
        {    break;
        }
        
        dbSync ( );
    }
    return;
}

Last edited by fanofcena (2010-12-31 00:09:56)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#2 2010-12-29 05:46:04

mhsuperyeah
Scratcher
Registered: 2010-03-19
Posts: 7

Re: Code for a game

Wow!

Offline

 

#3 2010-12-29 05:47:39

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

smile  .. lol i am C++ guy rather then scratch but i love to share knowledge sooooo :$ :$ enjoy XD


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#4 2010-12-29 06:26:50

Rik408
Scratcher
Registered: 2008-06-19
Posts: 100+

Re: Code for a game

I really wish I could help. I tried to learn C++, but I had a "BRAIN OVURLOAD!" Moment and gave up. I could code in batch then some fool could translate it to C++? XD


http://i.imgur.com/ILdKn.pnghttp://gifninja.com/animatedgifs/478756/food.gif

Offline

 

#5 2010-12-29 06:40:45

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

Rik408 wrote:

I really wish I could help. I tried to learn C++, but I had a "BRAIN OVURLOAD!" Moment and gave up. I could code in batch then some fool could translate it to C++? XD

Lol i coding it to C++ u need to convert it to scratch (A) ..

Its fairly hard to learn C++ though but i can teach any1 C++ in 30 mins (if he has got a good IQ and good knowledge  of scratch)  big_smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#6 2010-12-29 10:15:19

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

Bump. As per paddle to sees idea  big_smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#7 2010-12-29 16:20:46

ChaoticD
Scratcher
Registered: 2008-06-11
Posts: 69

Re: Code for a game

nice


ChaoticD/Daniel G.
Gaming Made Greater

Offline

 

#8 2010-12-30 11:24:56

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

Thank yew  smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#9 2010-12-31 11:52:02

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

sad  Nobody Intrested  sad  .. mods can close the post if they want tys  smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#10 2011-01-09 10:15:15

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

don't close! This is awesome.
Btw, fanofcena, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial? I'm working my way through the code right now, its really simple actualy.

Edit: Just full of functions I don't know of/understand.(And things that I don't yet know of)

Last edited by markyparky56 (2011-01-09 10:16:10)


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#11 2011-01-09 10:30:06

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

markyparky56 wrote:

, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial?

Exams and RADIO are taking most of my time , after my finals end i will have 3 months i will make a whole Series of Lets learn to code thingies teaching C++ and how to make things and stuff wiv programming + how to think computational .. the only problem is time management (I AM OVERBURDENED x) )


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#12 2011-01-09 10:41:53

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

markyparky56 wrote:

, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial?

Exams and RADIO are taking most of my time , after my finals end i will have 3 months i will make a whole Series of Lets learn to code thingies teaching C++ and how to make things and stuff wiv programming + how to think computational .. the only problem is time management (I AM OVERBURDENED x) )

When do you have your finals?

About the code...

Code:

charac Players[16];

2 things:

1. that makes 17 characters, if as you say in the comments next to it

//The players in game where 0 is the base player

2. Are these only bots and the Player himself is the 18th? make it a 9V9 game?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#13 2011-01-09 10:45:19

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

markyparky56 wrote:

fanofcena wrote:

markyparky56 wrote:

, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial?

Exams and RADIO are taking most of my time , after my finals end i will have 3 months i will make a whole Series of Lets learn to code thingies teaching C++ and how to make things and stuff wiv programming + how to think computational .. the only problem is time management (I AM OVERBURDENED x) )

When do you have your finals?

About the code...

Code:

charac Players[16];

2 things:

1. that makes 17 characters, if as you say in the comments next to it

//The players in game where 0 is the base player

2. Are these only bots and the Player himself is the 18th? make it a 9V9 game?

well my finals are varied starting from 1st march to 4th June (ending wiv SAT entrance test) .. sooo well its long time from now lol

and

Code:

charac Players[16];

That makes 16 players sire , with indexes 0 - 15 (where 0 is the initial players number in the array and 15 the last players index in the array) , Now Human Player is 0th indexed object in the list i made the class declarations (that i didnt pasted cuz they were way too big )such that they take input from Key board / Mouse if the Object is player and Automatically Decide what to do if Object is to be a bot . so it saves a lot of pain  smile  rather then making different objects also helps in fast and sleek runtime  smile  .

Last edited by fanofcena (2011-01-09 10:46:36)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#14 2011-01-09 10:50:09

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

markyparky56 wrote:

fanofcena wrote:

markyparky56 wrote:

, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial?

Exams and RADIO are taking most of my time , after my finals end i will have 3 months i will make a whole Series of Lets learn to code thingies teaching C++ and how to make things and stuff wiv programming + how to think computational .. the only problem is time management (I AM OVERBURDENED x) )

When do you have your finals?

About the code...

Code:

charac Players[16];

2 things:

1. that makes 17 characters, if as you say in the comments next to it

2. Are these only bots and the Player himself is the 18th? make it a 9V9 game?

well my finals are varied starting from 1st march to 4th June (ending wiv SAT entrance test) .. sooo well its long time from now lol

and

Code:

charac Players[16];

That makes 16 players sire , with indexes 0 - 15 (where 0 is the initial players number in the array and 15 the last players index in the array) , Now Human Player is 0th indexed object in the list i made the class declarations (that i didnt pasted cuz they were way too big )such that they take input from Key board / Mouse if the Object is player and Automatically Decide what to do if Object is to be a bot . so it saves a lot of pain  smile  rather then making different objects also helps in fast and sleek runtime  smile  .

Now thats just confusing me, why would it be [16] if the base is 0?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#15 2011-01-10 03:56:58

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

markyparky56 wrote:

fanofcena wrote:

markyparky56 wrote:

fanofcena wrote:

markyparky56 wrote:

, if you can teach anyone C++ in 30 minutes, why don't you create a tutorial?

Exams and RADIO are taking most of my time , after my finals end i will have 3 months i will make a whole Series of Lets learn to code thingies teaching C++ and how to make things and stuff wiv programming + how to think computational .. the only problem is time management (I AM OVERBURDENED x) )

When do you have your finals?


well my finals are varied starting from 1st march to 4th June (ending wiv SAT entrance test) .. sooo well its long time from now lol

and

Code:

charac Players[16];

That makes 16 players sire , with indexes 0 - 15 (where 0 is the initial players number in the array and 15 the last players index in the array) , Now Human Player is 0th indexed object in the list i made the class declarations (that i didnt pasted cuz they were way too big )such that they take input from Key board / Mouse if the Object is player and Automatically Decide what to do if Object is to be a bot . so it saves a lot of pain  smile  rather then making different objects also helps in fast and sleek runtime  smile  .

Now thats just confusing me, why would it be [16] if the base is 0?

C++ makes arrays like ::

int Arr[3];// will declare an array of 3 elements
              //Such that  Arr[0] - First element
              //Such that  Arr[1]-  Second Element
              //Such that  Arr[2] - Third Element  smile 

smile  i think that will solve ur confusion  smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#16 2011-01-11 11:22:10

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

markyparky56 wrote:

fanofcena wrote:


well my finals are varied starting from 1st march to 4th June (ending wiv SAT entrance test) .. sooo well its long time from now lol

and

Code:

charac Players[16];

That makes 16 players sire , with indexes 0 - 15 (where 0 is the initial players number in the array and 15 the last players index in the array) , Now Human Player is 0th indexed object in the list i made the class declarations (that i didnt pasted cuz they were way too big )such that they take input from Key board / Mouse if the Object is player and Automatically Decide what to do if Object is to be a bot . so it saves a lot of pain  smile  rather then making different objects also helps in fast and sleek runtime  smile  .

Now thats just confusing me, why would it be [16] if the base is 0?

C++ makes arrays like ::

int Arr[3];// will declare an array of 3 elements
              //Such that  Arr[0] - First element
              //Such that  Arr[1]-  Second Element
              //Such that  Arr[2] - Third Element  smile 

smile  i think that will solve ur confusion  smile

So it creates 3 elements, that makes sense.

Is this game 2D or 3D? (I'm geusing 3D since its DarkGDK) Where'd you get models for spartans?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#17 2011-01-12 09:27:44

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

markyparky56 wrote:

fanofcena wrote:

markyparky56 wrote:


Now thats just confusing me, why would it be [16] if the base is 0?

C++ makes arrays like ::

int Arr[3];// will declare an array of 3 elements
              //Such that  Arr[0] - First element
              //Such that  Arr[1]-  Second Element
              //Such that  Arr[2] - Third Element  smile 

smile  i think that will solve ur confusion  smile

So it creates 3 elements, that makes sense.

Is this game 2D or 3D? (I'm geusing 3D since its DarkGDK) Where'd you get models for spartans?

its 2.5 D for sake of simplicity

and getting models isnt a big deal .. when u can make them themselves or you can code something to export .skp files as .x  wink


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#18 2011-01-12 11:56:11

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

markyparky56 wrote:

fanofcena wrote:


C++ makes arrays like ::

int Arr[3];// will declare an array of 3 elements
              //Such that  Arr[0] - First element
              //Such that  Arr[1]-  Second Element
              //Such that  Arr[2] - Third Element  smile 

smile  i think that will solve ur confusion  smile

So it creates 3 elements, that makes sense.

Is this game 2D or 3D? (I'm geusing 3D since its DarkGDK) Where'd you get models for spartans?

its 2.5 D for sake of simplicity

and getting models isnt a big deal .. when u can make them themselves or you can code something to export .skp files as .x  wink

so its like a side scroller? And I think 2.5D is harder than 2D and 3D...


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#19 2011-01-13 00:00:06

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

2.5D is easier then 3d but harder then 2D  wink  .


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#20 2011-01-13 11:12:21

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

2.5D is easier then 3d but harder then 2D  wink  .

2.5D is just 2D with depth. And the camera can rotate on all three axises


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#21 2011-01-14 00:47:56

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

lol its easier to programm when u need to code AI and wall detection  wink


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#22 2011-01-14 08:37:20

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

lol its easier to programm when u need to code AI and wall detection  wink

But less realistic.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#23 2011-01-16 08:19:57

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

bump.

How long until the game will be done?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#24 2011-01-17 06:06:20

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Code for a game

idk (A) i have exams!


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#25 2011-01-17 11:19:53

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Code for a game

fanofcena wrote:

idk (A) i have exams!

Ok. Just wondering.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer