Thursday, July 10, 2014

Sidescrolling code snippet

Sidescrolling code by Ibrahim Ali Khan 

Sidescrolling code which can be a starter for many games. This was made in Visual C++ 2007. According to Ibrahim this was inspired by the side scrolling game flappy bird.


 
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <ctime>
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
void gotoxy(int x, int y)
{
 COORD pos;
 pos.X = x;
 pos.Y = y;
 SetConsoleCursorPosition(console, pos);
}
void box();
using namespace std;
void main ()
{
 for(int a=0;a<=10;a++)
 {
  box();
 }
}

void box()
{
 srand(time(0));
 int a,e=rand()%19+1,h=3,max=15;
 e=rand()%19+1; e=rand()%19+1; e=(rand()+rand()+rand()+rand())%19+1;
 if(e>15)
 {
  e=13;
 }
 if(e<4 data-blogger-escaped-a="10;a" data-blogger-escaped-e="4;" data-blogger-escaped-for="">=0;a--) //movement
 {
A:  int d=0;
  if(a==0)
  {
   for(int f=0;f<=19;f++)
   {
    gotoxy(a,d++);
    for(int g=h;g>=0;g--)
    {
     if(d>=e && d<=e+4)
     {
      cout<<" ";
     }
     else
     {
      cout<<(char)219;
     }
    }
   }
   if(h==-1)
   {
    break;
   }
   else
   {
    h--;
    Sleep(40);
    system("cls");
    goto A;
   }
  }
  for(int b=0;b<=19;b++) //length
  {
   gotoxy(a,d++);
   for(int c=0;c<=4;c++) //width
   {
    if(d>=e && d<=e+4)
    {
     cout<<" ";
    }
    else
    {
     cout<<(char)219;
    }
   }
  }
  Sleep(40);
  system("cls");
 }
}

Widgets

 

Copyright @ 2014 CPP Fuzz.