I have made a multi-platform Snake clone in C using OpenGL and GLUT. I am a beginner in graphic game development. I would like to add more features, but I have programmed the base game so far. I would love it if you could review my code and tell me how to make it better. Basic Snake HTML Game. Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader. I have a blog in which you can find some projects. Graphics and Game Programming in OpenGL My intention of creating that blog was to let students to do projects on their own. This is a cross-platform implementation of the classical game called snake. It is written in C and it uses ncurses and OpenGL /GLUT. As of right now, this is only a sample project that I created to learn how to use Git and other open-source technologies, as well as to get some actual programming expirience.
Opengl Snake Game Source Codes
This project is my second-year mini-project. I have use the GLUT(OpenGL) library in c++.3D Bounce is a game in which we have to bounce the ball to collect the floating star,after collecting all star then a door opens for the next room. Due to lack of time, I can't complete this project but all image drawing part is completed and I hope you will complete it for your collage project.You can download it source code from this link http://www.4shared.com/file/J-cjGaN-/bounce.html .This program is written in complete object oriented environment ,I have made different class in different file and It's code is very lengthy so I can't give source code here.
List of class that I have made are:-
loadBMP.h //file use for loading bitmap image for texture map
class Image {
public:
Image(char* ps, int w, int h);
~Image();
char* pixels;
int width;
int height;
};
Image* loadBMP(const char* filename);
//Reads a bitmap image from file.
drawing.h //all image drawing for game content in this file
#include <glut.h>
#include <iostream>
//#include <stdio.h>
//#include <math.h>
#include 'loadBMP.h'
class Ball; //creating object for class ball
typedef struct
{
int X;
int Y;
int Z;
double U;
double V;
}VERTICES;
class drawing
{
private:
Ball *ball;
GLuint _cellingtextureID;
GLuint _walltextureID;
GLuint _floortextureID;
GLuint _secondfloortextureID;
GLuint _cubetextureID;
GLuint _gatetextureID;
GLuint _balltextureID;
GLuint _poletextureID;
GLuint _foodtextureID;
//GLuint _gatetextureID;
GLint CELL;
GLint poleDisplayList;
GLint gateDisplayList;
GLint roomDisplayList;
GLint cubeDisplayList;
GLint foodDisplayList;
GLuint menuDisplayList;
/*const*/ int space;// = 10;
/*const*/ int VertexCount;// = (90 / space) * (360 / space) * 4;
VERTICES *VERTEX;//[VertexCount];
int PI;
GLfloat CELL2;
GLfloat CUBE_POS;
GLfloat FOOD_POS;
int cube_ran_pos[6][6];
int food_ran_pos[4][4];
bool Gamestart;
void startwindow();
void drawRoom();
void drawBall();
void setupPole();
void setupGate();
void drawcube();
void drawFood();
void DisplaySphere(double);
//void drawGate();
void drawPole_and_Gate();
void setupLighting();
//int random_num(int);
public:
drawing();
void CreateSphere (double R, double H, double K, double Z);
void callBallConstructor();
//void setdrawing();
void draw();
~drawing();
void checkleftkey();
void checkrightkey();
void checkupkey();
void checkdownkey();
};
//this class used to draw image
game.h //this file content ball class from where all ball action is controled
//#include<vector>
#include <glut.h>
//const float BARRIER_SIZE = 0.12f;
class Ball {
private:
//The radius of the ball
float r;
//The x coordinate of the ball
float x0;
//The y coordinate of the ball
float y0;
//The z coordinate of the ball
float z0;
//The angle at which the ball is traveling. An angle of 0 indicates the
//positive x direction, while an angle of PI / 2 indicates the positive
//z direction. The angle is always between 0 and 2 * PI.
float angle0;
//The fraction that the ball is 'faded in', from 0 to 1. It is not 1
//when the ball is fading in or out.
float fadeAmount0;
//Whether the ball is fading out
bool isFadingOut0;
//collision detection
void DetectCollision();
public:
//Constructs a new ball with the specified radius, x, y and z coordinates,
//and angle of travel. An angle of 0 indicates the positive x
//direction, while an angle of PI / 2 indicates the positive z
//direction. The angle must be between 0 and 2 * PI.
Ball();
//Returns the radius of the ball
float radius();
//Returns the x coordinate of the ball
float x();
//returns the z coordinate of the ball
float y();
//Returns the z coordinate of the ball
float z();
//Returns the angle at which the ball is traveling. An angle of 0
//indicates the positive x direction, while an angle of PI / 2 indicates
//the positive z direction. The returned angle is between 0 and 2 * PI.
float angle();
//Causes the ball to begin fading out
void fadeOut();
//Returns whether the ball is fading out
bool isFadingOut();
//sets the angle of ball
void setangle();
//checks whether the left key is pressed
void checkleftkey();
//checks whether the right key is pressed
void checkrightkey();
//checks whether the up key is currently depressed
void checkupkey();
//checks whether the down key is currently depressed
void checkdownkey();
};
I hope you guys got a little idea about this game. Download it's complete source code and compiled it in code block or visual studio but don't forget to set up GLUT(OpenGL).
Thank you.
Code Directory |
---|
ASP ASP.NET C/C++ CFML CGI/PERL Delphi Development Flash HTML Java JavaScript Pascal PHP Python SQL Tools Visual Basic & VB.NET XML
|
New Code |
---|
The C# OCR Library 2020.11 | SentiVeillance SDK Trial 7.3.2020.11.30 | VaxVoIP WebPhone SDK 4.0.6.0 | SentiMask SDK Trial 2.0_193121 | C# QR Code Generator 2020.12 | How to Read Text from an Image in C# 2020.12 | The .Net PDF Library 2020.12.3 | fsMediaLibrary.NET 2019.11.0 | Entity Developer 6.9.1112 | OrgChart JS 7.5.40 | LinqConnect 4.9.2096 | SSIS Data Flow Components 1.15 | IP2Location Geolocation Database Oct.2020 | Luxand FaceSDK 7.2 | dbForge Data Compare for PostgreSQL 3.3.6 |
|
Top Code |
---|
Uber Clone with Safety Measure Addons 2.0 | Answers phpSoftPro 3.12 | phpEnter 5.1. | Quick Maps For Dynamics CRM 3.1 | Single Leg MLM 1.2.1 | Azizi search engine script PHP 4.1.10 | Paste phpSoftPro 1.4.1 | Extreme Injector 3.7 | Apphitect Airbnb Clone Script 1.0 | Deals and Discounts Website Script 1.0.2 | Pro MLM 1 | Solid File System OS edition 5.1 | Classified Ad Lister 1.0 | Aglowsoft SQL Query Tools 8.2 | ICPennyBid Penny Auction Script 4.0 |
|
Top Search |
---|
Mmn Affiliate | Ppi Affiliate | How To Update Delete Insert In Php | Ebay Affiliate | Multiple Membership Affiliate | Dirty Word | Code To Add Url | Source Code For Dot And Box Game | Photo Add Comment Php | Fubar Mafia Bots | Fantasy Cricket Game | Srs For Online Art Gallery | Gallery Comment | Php Link Directory | Autopilot Farming |
|
Related Search |
---|
Snake Opengl | Snake Opengl Codes | Snake Opengl C | Snake And Ladder In Opengl | Animated Snake Code In Opengl | Opengl Code For Snake And Ladder | Source Code For Snake Game Using Opengl | Source Code For Snake Game In Opengl | Snake Code In Opengl | Snake And Ladder Game Codes Using Opengl | Snake And Ladders In Opengl | Opengl Snake | Opengl Code For Snake N Ladder | Snake And Ladder Code For Opengl | Snake And Ladder Game In Opengl Code |
|
| Snake Opengl |
---|
Code 1-20 of 60 Pages: Go to 1 23Next >> page | 3D World (OpenGL walk through city)... - Dustin Davis This code is the starting point of any 3d gamer's quest to design a 3d game. It will show you how to use openGL to load and display 3d models and show you basic keyboard input along with mouse input. Move around just like in UT or Half-Life. Use mouse look, strafe and take a nice walk around this very very small city. Make sure to extract the 3dworld folder to c:windowsdesktop otherwise the textures wont work! C/C++ / Games And Entertainment RED SNAKE GAME presents you a snake that eats everything. The code is very simple to understand. C/C++ / Games And Entertainment Snake game C is a classical game of snake.
C/C++ / Games And Entertainment This is the classic game of snake. The more apples you eat the more longer your tail is. The more levels you comlete the faster you go!. The code is written with with all the basic header files. No graphics.h or allegro.h. C/C++ / Image Manipulation OpenGl 3D Effect code creates a nice effect of crumbling in 3D. It simply takes a picture and decomposes it in tiny particles (their size can be specified). C/C++ / Image Manipulation OpenGL Demos codes are a couple demos that tests the basic framework of a graphic engine. Python / Games and Entertainment Graphic representation of the classic Rubik Snake toy. Utility to create and manage a snake, a clock made of snakes, and two demo files that explain how to make your own snake or snake like graphics using handle graphics. Snake (the classic Nokia game) 1.0 - Per-Anders Ekstrom The Game: Make the snake grow longer by directing it to the food. Extra bonus points are given from hearts, eat them as fast as possible as amount of bonus points decreases with time. Higher level gives more points for the food but... Tools / Development Tools ruby-opengl is software that lets you write OpenGL programs in Ruby. Specifically, it primarily consists of extension modules that wrap OpenGL and GLUT. Ruby bindings for OpenGL and GLUT 0.60.1 - Alain Hoang ruby-opengl is software that lets you write OpenGL programs in Ruby. Specifically, it primarily consists of extension modules that wrap OpenGL and GLUT. Delphi / Graphical Controls OpenGl label for Delphi 5.0.Cool 3d rotating label and component for easy drawing in OpenGl on a form. JavaScript / Scripts and Programs / Games and Entertainment Snake is a game in DHTML that can entertain the visitors of our page. The game can be played using the arrow keys of the keyboard. Few blocks are displayed on the game area and the user has to join up these blocks by navigating the snake using the... Delphi / Games Feed the Snake is a new modern remake of the popular classic snake game. You are a little snake. The goal of the game is grow, grow and grow. You start as a small worm, but you may end as a mighty python. To grow you need a food. This won't the... MNOgl component collection version 1.0 - Leopold Minikus Component collection to develope OpenGL applications completly component based and full WYSIWYG support already in design mode Delphi / Miscellaneous This is the next version of OpenGL.pas, the interface unit to the 3D library OpenGL. It provides access to MS and SGI DLLs up to version 1.1 and is prepared for the upcoming v1.2 (+extensions). Included are functions for context creation and... MNOgl OpenGL component collection 1.0 - Leopold Minikus, Wolfgang Nagl The MNOgl component collection is a high performance and high quality set of OpenGL tools developed to support you and to give you the possibility to rapidly develop OpenGL extensions for new and further applications but also to extend existing... Delphi / Multimedia OpenGL components for multiple Installable Client Drivers (ICD). Pad images to power-of-two dimensions . - Martin Wilson Pads any amount of images each to power-of-two dimensions, useful for OpenGL programming. Use wxPython/OpenGL to draw a sphere - Rick Muller A simple wxPython/OpenGL application to draw a sphere. Open a GLUT window and draw a sphere... - Rick Muller This code snippet uses Python/OpenGL (http://pyopengl.sourceforge.net) to open a window using GLUT, and draw a sphere into it. I've used this many times as the starting point for more complicated applications. |
|
Opengl Snake Game Source Code Free
Home|Submit Code|Submit URL|Top Code Search|Last Code Search|Privacy Policy|Link to Us|Contact |