• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Page 1 of 2 12 LastLast
    Results 1 to 10 of 13
    1. #1
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      voidisalive's Avatar
      Join Date
      May 2012
      Posts
      68
      Thanks (-->)
      1
      Thanks (<--)
      14

      C++ Snake Game Weekend Project 2012.08.26

      John Kittz
      Hey guys this past weekend I worked on this classic Snake Game I hope you guys like it as much as I do if you want anything added on it let me know and I will add new stuff.


      Download Game here + Source code
      https://www.4shared.com/rar/p_8COaNV...l?refurl=d1url

      video
      https://www.youtube.com/watch?v=qjY87q-M3nA

      main.h
      Code:
      //Author: voidisalive
      #include <iostream>
      #include <conio.h>
      #include <windows.h>
      #include <stdlib.h>
      
      #pragma comment( lib, "Winmm.lib" )
      
      //Defines
      #define UP 72
      #define DOWN 80
      #define LEFT 75
      #define RIGHT 77
      #define ESC 27
      
      
      //Game Variables
      int snake_body[200][2];
      int _ini_pos = 1;
      int _snake_size = 3;
      int _iniX = 10;
      int _iniY = 15;
      int _xTar = 30;
      int _yTar = 15;
      int _snake_direction = 3;
      int _snake_speed = 80;
      int _heurestica = 1;
      int _score = 0;
      char movement_key;
      
      //Set stuff at X and Y Pos Routine
      void _posXY( int _x, int _y )
      {
      		HANDLE hCon;
      	COORD dwPos;
      
      	dwPos.X = _x;
      	dwPos.Y = _y;
      
      	hCon = GetStdHandle(STD_OUTPUT_HANDLE);
      	SetConsoleCursorPosition(hCon, dwPos);
      }
      //Draw Routine
      void draw_board( void )
      {
      	//horizontal lines
      	for( int c = 1; c < 78; c++)
      	{
      		_posXY(c, 1);
      		printf("%c", 220);
      		_posXY(c, 23);
      		printf("%c", 220);
      	}
      	//vertical lines
      	for( int c = 3; c < 23; c++)
      	{
      		_posXY(1, c);
      		printf("%c", 219);
      		_posXY(77, c);
      		printf("%c", 219);
      	}
      	//corner top left
      	_posXY(1,2);
      	printf("%c", 219);
      	//corner bottom left
      	_posXY(1,23);
      	printf("%c", 219);
      	//corner top right
      	_posXY(77,2);
      	printf("%c", 219);
      	//corner bottom right
      	_posXY(77, 23);
      	printf("%c", 219);
      }
      //Store... Save snake Position Routine
      inline void store_snake_pos( void )
      {
      	snake_body[_ini_pos][0] = _iniX;
      	snake_body[_ini_pos][1] = _iniY;
      	_ini_pos++;
      	if( _ini_pos == _snake_size )
      	{
      		_ini_pos = 1;
      	}
      }
      //Draw Snake body Routine
      inline void draw_snake_body( void )
      {
      	for( int c = 1; c < _snake_size; c++ )
      	{
      		_posXY( snake_body[c][0], snake_body[c][1] );
      		printf("%c", 2);
      	}
      }
      //Remove Snake Body Routine
      inline void rem_snake_body( void )
      {
      		_posXY( snake_body[_ini_pos][0], snake_body[_ini_pos][1] );
      		printf(" ");
      }
      //Move Snake Routine
      inline void mov_snake( void )
      {
      	if( kbhit() )
      		{
      			movement_key = getch();
      			switch( movement_key )
      			{
      				case UP:
      					if( _snake_direction != 2 )
      					{
      						_snake_direction = 1;
      					}
      					break;
      				case DOWN:
      					if( _snake_direction != 1 )
      					{
      						_snake_direction = 2;
      					}
      					break;
      				case RIGHT:
      					if(  _snake_direction != 4 )
      					{
      						 _snake_direction = 3;
      					}
      					break;
      				case LEFT:
      					if(  _snake_direction != 3 )
      					{
      						 _snake_direction = 4;
      					}
      					break;
      			}//EOF switch
      		}//EOF if
      }
      //Add target to snake body Routine
      inline void inc_snake_size( void )
      {
      	if(_iniX == _xTar && _iniY == _yTar)
      	{
      		PlaySound(TEXT("Coin.wav"), NULL, SND_FILENAME | SND_ASYNC);
      		_xTar = (rand()%73)+4;
      		_yTar = (rand()%19)+4;
      		_snake_size+=1;
      		_score+=5;
      		_posXY(_xTar, _yTar);
      		printf("%c", 3);
      	}
      }
      //Game over Routine
      inline bool b_game_over()
      {
      	if( _iniY == 1 || _iniY == 23 || _iniX == 1 || _iniX == 77 )
      	{
      		PlaySound(TEXT("GameOver.wav"), NULL, SND_FILENAME | SND_ASYNC);
      		return false;
      	}
      		
      	for( int c = _snake_size -1; c > 0; c-- )
      	{
      		if( snake_body[c][0] == _iniX && snake_body[c][1] == _iniY)
      			return false;
      	}
      	return true;
      }
      //Score Routine
      inline void score( void )
      {
      	_posXY(35, 0);
      	printf("Score: %d", _score);
      }
      //Inc snake speed Routine
      inline void inc_speed( void )
      {
      	if(_score == _heurestica*15)
      	{
      		_snake_speed -=10;
      		_heurestica+=1;
      	}
      }
      main.cpp
      Code:
      //Author: voidisalive
      #include "main.h"
      
      using namespace std;
      
      int main()
      {
      	SetConsoleTitle("Console Snake");
      	::MessageBoxA(NULL, "Cpp Snake game by voidisalive" , "voidisalive", MB_OK | MB_ICONEXCLAMATION);
      	draw_board();
      	_posXY(_xTar, _yTar);
      	printf("%c", 3);
      
      	while(movement_key != ESC && b_game_over())
      	{
      		rem_snake_body();
      		store_snake_pos();
      		draw_snake_body();
      		inc_snake_size();
      		score();
      		inc_speed();
      		mov_snake();
      		mov_snake();
      		mov_snake();
      		if(  _snake_direction == 1 )
      		{
      			_iniY--;
      		}
      		if(  _snake_direction == 2 )
      		{
      			_iniY+=1;
      		}
      		if(  _snake_direction == 3 )
      		{
      			_iniX+=1;
      		}
      		if(  _snake_direction == 4 )
      		{
      			_iniX-=1;
      		}
      		Sleep(_snake_speed);
      	}
      	if(b_game_over() == false)
      	{
      		_posXY(35,10);
      		printf("GAME OVER");
      	}
      	
      	
      	system("pause>>null");
      	return 0;
      }
      virus scan
      https://virusscan.jotti.org/en/scanr...417a4a720a7a21

      Greets,

      voidisalive
      Last edited by voidisalive; 08-27-2012 at 01:32 PM.

    2. Thanks Fleep, c5, Crazywink, Glenox thanked for this post
    3. #2
      Hacker
      Learning to hack games!
       
      Pawning
       
      Fleep's Avatar
      Join Date
      May 2012
      Posts
      626
      Thanks (-->)
      208
      Thanks (<--)
      727
      Seems great, would love to see a screenshot

      Fleep

    4. Thanks voidisalive thanked for this post
    5. #3
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      voidisalive's Avatar
      Join Date
      May 2012
      Posts
      68
      Thanks (-->)
      1
      Thanks (<--)
      14
      Thanks Fleep I'm uploading a small video shows the game in action I was bored reversing BF3 and I tough about making another console game I think I might create one in Direct X for when I get bored ingame I play sum snake I love this game.

      video
      https://www.youtube.com/watch?v=qjY87q-M3nA

    6. Thanks Fleep thanked for this post
    7. #4
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      It's really great that you share source codes with us, that way everyone can benefit from the game in one way or another Thanks!
      C++ Snake Game Weekend Project 2012.08.26

    8. #5
      Hacker
      Learning to hack games!
       
      Pawning
       
      Fleep's Avatar
      Join Date
      May 2012
      Posts
      626
      Thanks (-->)
      208
      Thanks (<--)
      727
      Absolutely, Great use of the Mario sounds as well!

      Fleep

    9. #6
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      voidisalive's Avatar
      Join Date
      May 2012
      Posts
      68
      Thanks (-->)
      1
      Thanks (<--)
      14
      Thanks c5 yeah I share the source because that way members can see how I work and do things altough i did this fast coding sunday night and some code is not so great but it pleases me and I have fun playing this game

      Edit:
      Thanks Fleep I was thinking of putting a sound when snake moves but I tough it was going to be to many sounds so I leave that to the users if they want to add a sound fxd for when the snake moves or background music, which ever one they prefer.

      Greets,

      voidisalive
      Last edited by voidisalive; 08-27-2012 at 01:42 PM.

    10. #7
      Hacker
      Retired
       
      Pawning
       
      Crazywink's Avatar
      Join Date
      Jul 2012
      Location
      US
      Posts
      647
      Thanks (-->)
      111
      Thanks (<--)
      226
      Wow, this is great! Good job void.

      Crazywink

    11. #8
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      voidisalive's Avatar
      Join Date
      May 2012
      Posts
      68
      Thanks (-->)
      1
      Thanks (<--)
      14
      Thanks crazy I'll probably be releasing another game I just have to think which game to do that would be for next weekend

    12. #9
      Coder
      Learning to hack games!
       
      Feeling Normal
       
      konsowa's Avatar
      Join Date
      May 2012
      Posts
      184
      Thanks (-->)
      1
      Thanks (<--)
      2
      Well done void, go for a mario game next will ya?
      Would luv to c u do that..

    13. #10
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      Cheats'n'Trainers
      I was doing a stickrun with windows forms, but creating new threads & initializing background workers and passing information to main form UI pissed me off so I cancelled it, but it was promising though
      C++ Snake Game Weekend Project 2012.08.26

    Page 1 of 2 12 LastLast

    Similar Game Hacker Threads

    1. crash c++/VS 2012
      By VDV777 in forum C/C++
      Replies: 4
      Last Post: 06-28-2013, 06:39 PM
    2. c++ VS 2012
      By VDV777 in forum C/C++
      Replies: 4
      Last Post: 04-25-2013, 09:41 AM
    3. Member of the Quarter [Q4 2012]
      By c5 in forum Member of the Quarter
      Replies: 15
      Last Post: 01-01-2013, 08:06 AM
    4. Anyone using Visual Studio 2012 right now?
      By shuuk in forum Hacking Help
      Replies: 15
      Last Post: 12-07-2012, 01:06 PM