collapse collapse

* Who's Online

  • Dot Guests: 72
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11164
  • stats Total Topics: 1700
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 1470

Author Topic: [21] Our first Console Game... Well, with graphics at least  (Read 16349 times)

0 Members and 1 Guest are viewing this topic.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
[21] Our first Console Game... Well, with graphics at least
« on: December 19, 2008, 02:48:57 pm »
There are two files this time.
A header, and a cpp file.

main.cpp
Code: [Select]
    
/******************************************************
//   $Program: Ascii Sonic!
//   
//   $Description: Our first attempt at a console
//      game. We will make a character travel
//      around the console window.
//   
*******************************************************/
#include "AsciiSonic.h"   // Notice we used quotes to include this time.
            // This means that we are telling the compiler to look in the local directory

HANDLE Keyboard;   // Our input device handle(keyboard)
HANDLE Monitor;      // Our console window is our output
CONSOLE_SCREEN_BUFFER_INFO Screen_Information;



void Draw_Sonic(SONIC temp, int Flag)
{
   if(Flag)
   {
      SetConsoleCursorPosition(Monitor, temp.Loc);
      cout << "O";
   }
   else
   {
      SetConsoleCursorPosition(Monitor, temp.Loc);
      cout << " ";
   }
}

void Move_Sonic(SONIC &temp)
{
   INPUT_RECORD record;
   DWORD data=0;
   ReadConsoleInput(Keyboard, &record, 1, &data);

   if(record.EventType == KEY_EVENT && record.Event.KeyEvent.bKeyDown) // Has to be a key event and it recognizes ONLY key down, not both down and up events
   {
      switch(record.Event.KeyEvent.wVirtualKeyCode)
      {
      case VK_RIGHT:
         {
            Draw_Sonic(temp, DESTROY);   // Erase our old sprite
         
            temp.Loc.X++;   // Set our new position
         
            if(temp.Loc.X < Screen_Information.srWindow.Right) // check we are not off the camera screen
            {
               temp.Loc.X = Screen_Information.srWindow.Right;   // go back if we are
            }
            Draw_Sonic(temp, CREATE);
            break;
         }                           
         

      case VK_LEFT:
         {
            Draw_Sonic(temp, DESTROY);   // Erase our old sprite
         
            temp.Loc.X--;   // Set our new position
         
            if(temp.Loc.Y < Screen_Information.srWindow.Left) // check we are not off the camera screen
            {
               temp.Loc.X = Screen_Information.srWindow.Left;   // go back if we are
            }
            Draw_Sonic(temp, CREATE);
            break;
         }

      case VK_UP:
         {
            Draw_Sonic(temp, DESTROY);   // Erase our old sprite
         
            temp.Loc.Y--;   // Set our new position
         
            if(temp.Loc.Y < Screen_Information.srWindow.Top) // check we are not off the camera screen
            {
               temp.Loc.Y = Screen_Information.srWindow.Top;   // go back if we are
            }
            Draw_Sonic(temp, CREATE);
            break;
         }

      case VK_DOWN:
         {
            Draw_Sonic(temp, DESTROY);   // Erase our old sprite
           
            temp.Loc.Y++;   // Set our new position
           
            if(temp.Loc.Y < Screen_Information.srWindow.Bottom) // check we are not off the camera screen
            {
               temp.Loc.Y = Screen_Information.srWindow.Bottom;   // go back if we are
            }
            Draw_Sonic(temp, CREATE);
            break;
         }
      }
   }
   

   FlushConsoleInputBuffer(Keyboard);

}

int main()
{
   SONIC Sonic;
   Keyboard   = GetStdHandle(STD_INPUT_HANDLE);
   Monitor      = GetStdHandle(STD_OUTPUT_HANDLE);

   SetConsoleMode(Monitor, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
   /**********************************************************************
   //   SetConsoleMode(1, 2);
   //      $1. First is our handle to the window
   //      $2. Here we use a '|', we basically OR'd it.
   //            This means it will enable both of those.
   ***********************************************************************/

   Sonic.Loc.X   =   WIDTH   /   2;
   Sonic.Loc.Y   =   HEIGHT   /   2;
   SetConsoleCursorPosition(Monitor, Sonic.Loc);

   while(true) // Our game loop
   {
      Move_Sonic(Sonic);
   }
   return 0;
}

AsciiSonic.h
Code: C++
  1. #include <windows.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. #define WIDTH   79      // Our movement area size x
  7. #define HEIGHT  24      // Our movement area size y
  8.  
  9. #define DESTROY 0       // Destroy image flag
  10. #define CREATE  1       // Create image flag
  11.  
  12. struct SONIC
  13. {
  14.         COORD   Loc;            // Location
  15.         int             Direction;      // Movement direction to the flags
  16. };
  17.  
  18. void Draw_Sonic(SONIC temp, int Flag);  // We will pass in our structure as well as our direct flag here.
  19. void Move_Sonic(SONIC &temp);                   // We will pass in our stracture as a reference here.
  20.                 /*****************************************************************
  21.                 //                                      - References -
  22.                 //      $ A reference is where you pass in a varaible by its memory value.
  23.                 //      $ To get the varaibles memory value, you add the '&' symbol
  24.                 //      $ before the variable like we did earlier in our Move_sonic
  25.                 //      $ function. This also allows us to manipulate the data and it
  26.                 //      $ will be permenent instead of just editing the copy that the function
  27.                 //      $ makes by it self that is localized.
  28.                 //     
  29.                 ******************************************************************/
  30.  
  31.  


[edited name=Celestialkey date=1260376628][/edited]
[edited name=Celestialkey date=1260376780][/edited]
[edited name=Celestialkey date=1260376891][/edited]
[edited name=Celestialkey date=1260529423][/edited]
« Last Edit: December 11, 2009, 05:09:57 am by Celestialkey »
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline GodLord

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 477
  • Reputation 800
  • Gender: Male
  • C++/Java Developer
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #1 on: January 13, 2009, 09:06:56 pm »
Yah this was an epic fail I tried to run your cpp with the header in and it had 28 errors is this normal?

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #2 on: January 13, 2009, 09:19:24 pm »
No -.-;

Posting the errors would be helpful.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline GodLord

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 477
  • Reputation 800
  • Gender: Male
  • C++/Java Developer
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #3 on: January 18, 2009, 05:34:23 pm »
Nvm I got it to work;however, there is no point and I think theres a 'bug' because when 'sonic' (0) hits the side it just prints zeroes whichever direction you go into.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #4 on: January 18, 2009, 05:42:28 pm »
Ah, thats because you have to have a limiter to the size of the area. I never placed it in allowing you to go beyond it thus causing glitches that you saw.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #5 on: November 29, 2009, 06:46:32 pm »
How to have a limiter to the size of the area??

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #6 on: November 29, 2009, 06:59:41 pm »
When it reaches the side, check if it can go farther, if it cant, just set it back to its previous position.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #7 on: November 29, 2009, 07:33:55 pm »
When i hit the right side of the prompt the O or Sonic is gonna appear at the left side of the prompt and it will print multiple O or multiple Sonic.

Code: [Select]
case VK_RIGHT:
{
Draw_Sonic(temp, DESTROY); // Erase our old sprite

temp.Loc.X++; // Set our new position

if(temp.Loc.X < Screen_Information.srWindow.Right) // check we are not off the camera screen
{
temp.Loc.X = Screen_Information.srWindow.Right; // go back if we are
}
Draw_Sonic(temp, CREATE);
break;
}

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #8 on: November 29, 2009, 10:00:31 pm »
Can someone post a screenshot? :)
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #9 on: November 30, 2009, 08:12:20 pm »


After Hitting the right side of the prompt.  :-\


Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #11 on: December 06, 2009, 05:19:17 am »
Sir Celestial Please HELP.  ???

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #12 on: December 06, 2009, 07:11:47 am »
I'll post a example code when I get back from my meeting.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #13 on: December 10, 2009, 09:45:11 pm »
I'm STUCKED! in here :-\

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #14 on: December 11, 2009, 05:13:11 am »
I just tested it out, for me, it stops it before it ever breaks outside the window edge. Perhaps your settings are different for your console window. In that case, replace Screen_Information.srWindow.Bottom With the height of your window, Screen_Information.srWindow.Top with 0, Screen_Information.srWindow.Left with 0, and Screen_Information.srWindow.Right with the width of the window.

In your case, it should ALREADY stop when it hits the top or left side right? It only does that when traveling to the right?
Sorry for the late response.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #15 on: December 11, 2009, 09:52:57 pm »
Quote
In your case, it should ALREADY stop when it hits the top or left side right? It only does that when traveling to the right?
Sorry for the late response.

Yup, it only does when i hit the right side.
I'm gonna try to debug it, but for now i need to download a new C++ compiler. My Microsoft Visual Studio is already hit its 30days! :D

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #16 on: December 11, 2009, 10:03:50 pm »
Microsoft Visual C++ or DevC++
Dev is no longer updated I think though.
Anyhow, I know this tutorial works with those two. No guarantees for the rest.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #17 on: December 12, 2009, 01:56:57 am »
Microsoft Visual C++ the only compiler i know.  :P

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #18 on: December 12, 2009, 10:47:44 am »
Quote
In your case, it should ALREADY stop when it hits the top or left side right? It only does that when traveling to the right?
Sorry for the late response.

Yup, it only does when i hit the right side.
I'm gonna try to debug it, but for now i need to download a new C++ compiler. My Microsoft Visual Studio is already hit its 30days! :D
What do you mean by 30 days? Visual Studio express is free.
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #19 on: December 12, 2009, 11:17:20 am »
But Microsoft Visual Studio is not. Studio version vs Express is different, studio contains all of the compilers and IDE's. he express editions are specific to one language.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #20 on: December 12, 2009, 11:22:08 am »
But Microsoft Visual Studio is not. Studio version vs Express is different, studio contains all of the compilers and IDE's. he express editions are specific to one language.
I do see your point. Last time I installed Visual Studio Express was years ago.
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #21 on: January 05, 2010, 02:53:49 am »
When i did this it produce more glitches.

Quote
   Screen_Information.srWindow.Bottom = 50;
   Screen_Information.srWindow.Top = 0;
   Screen_Information.srWindow.Left = 0;
   Screen_Information.srWindow.Right = 80;

Heres the code:

Code: [Select]
// ConsoleApplication1.cpp : main project file.
#include "stdafx.h"
#include "AsciiSonic.h"

HANDLE Keyboard = GetStdHandle(STD_INPUT_HANDLE);
HANDLE Monitor = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO Screen_Information;



void Draw_Sonic(SONIC temp, int Flag)
{
if(Flag)
{
SetConsoleCursorPosition(Monitor, temp.Loc);
cout << "O";
}
else
{
SetConsoleCursorPosition(Monitor, temp.Loc);
cout << " ";
}
}

void Move_Sonic(SONIC &temp)
{
INPUT_RECORD record;
DWORD data = 0;
ReadConsoleInput(Keyboard, &record, 1 , &data);

if(record.EventType == KEY_EVENT && record.Event.KeyEvent.bKeyDown)
{
switch(record.Event.KeyEvent.wVirtualKeyCode)
{
case VK_RIGHT:
Draw_Sonic(temp, DESTROY);
temp.Loc.X++;
if(temp.Loc.X < Screen_Information.srWindow.Right)
{
temp.Loc.X = Screen_Information.srWindow.Right;
}
Draw_Sonic(temp, CREATE);
break;
case VK_LEFT:
Draw_Sonic(temp, DESTROY);
temp.Loc.X--;
if(temp.Loc.X < Screen_Information.srWindow.Left)
{
temp.Loc.X = Screen_Information.srWindow.Left;
}
Draw_Sonic(temp, CREATE);
break;
case VK_UP:
Draw_Sonic(temp, DESTROY);
temp.Loc.Y--;
if(temp.Loc.Y < Screen_Information.srWindow.Top)
{
temp.Loc.Y = Screen_Information.srWindow.Top;
}
Draw_Sonic(temp, CREATE);
break;
case VK_DOWN:
Draw_Sonic(temp, DESTROY);
temp.Loc.Y++;
if(temp.Loc.Y < Screen_Information.srWindow.Bottom)
{
temp.Loc.Y = Screen_Information.srWindow.Bottom;
}
Draw_Sonic(temp, CREATE);
break;
}
}
FlushConsoleInputBuffer(Keyboard);
}


int main()
{
SONIC Sonic;

SetConsoleMode(Monitor, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);

SetConsoleTitle(L"Do'in your mom!");

SMALL_RECT WindowSize = {0, 0, 79, 49};

SetConsoleWindowInfo(Monitor, TRUE, &WindowSize);

COORD BufferSize = {80, 50};

SetConsoleScreenBufferSize(Monitor, BufferSize);

Screen_Information.srWindow.Bottom = 50;
Screen_Information.srWindow.Top = 0;
Screen_Information.srWindow.Left = 0;
Screen_Information.srWindow.Right = 80;

Sonic.Loc.X = WIDTH / 2;
Sonic.Loc.Y = HEIGHT / 2;
SetConsoleCursorPosition(Monitor, Sonic.Loc);
while(true)
{
Move_Sonic(Sonic);
}
return 0;
}

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #22 on: January 05, 2010, 12:22:53 pm »
That windows rectangle is off. The top left position should be initialized to wherever the top left part of the window is. Meaning it's not 0, 0. The window is in the center of the screen so its at least 100, 100.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #23 on: January 05, 2010, 12:33:40 pm »
but SIR what about the glitches on the right side and the bottom side?

I need to make it stop there, I've been thinking about making my own PAC_MAN game.

btw thanks for your patience.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #24 on: January 05, 2010, 01:14:03 pm »
but SIR

Lol...

To check those, just make sure that sonics current position is NOT farther to the right than your map. Check his X position. If it is greater than the maps width, you set him back to 0 or his last position. Something is wrong with your settings to cause it to fail. Or a check is not being called.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #25 on: January 05, 2010, 03:03:41 pm »
Somewhere along the lines, you messed the code up. Here is a example that works for me. I can not go too far to the right or left or up or down.
All I did was use the original example, and used MoveWindow in the int main to modify it's size.

I suggest you revert to the old code since yours somehow got modified.
My "int main" modification
Code: C++
  1. int main()
  2. {
  3.    SONIC Sonic;
  4.    Keyboard   = GetStdHandle(STD_INPUT_HANDLE);
  5.    Monitor      = GetStdHandle(STD_OUTPUT_HANDLE);
  6.  
  7.    SetConsoleMode(Monitor, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
  8.    HWND h = GetConsoleWindow();
  9.    MoveWindow(h, 0, 0, 100, 100, true);
  10.  
  11.    Sonic.Loc.X   =   WIDTH   /   2;
  12.    Sonic.Loc.Y   =   HEIGHT   /   2;
  13.    SetConsoleCursorPosition(Monitor, Sonic.Loc);
  14.  
  15.    while(true) // Our game loop
  16.    {
  17.       Move_Sonic(Sonic);
  18.    }
  19.    return 0;
  20. }
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #26 on: January 05, 2010, 07:56:25 pm »
Sir its like there is something wrong with the KeyCode: the VK_RIGHT, VK_LEFT, VK_DOWN, VK_DOWN
I try to remove VK_RIGHT, VK_LEFT, VK_DOWN, VK_DOWN but still I can hit the right, left , up. down arrow keys? but how?

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #27 on: January 05, 2010, 10:07:19 pm »
I don't know. Revert to the original code. When you start changing stuff. Debug the app RIGHT after the change so you can see the results. You should have noticed the errors in the process.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline ifyoudearthis

  • Jr. Member
  • **
  • Posts: 94
  • Reputation 118
    • View Profile
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #28 on: January 05, 2010, 10:23:45 pm »

Or a check is not being called.

I've think the problem is with the if statements in case  VK_RIGHT: and case VK_LEFT:, I think the program skip at that part what should i do if such problem occur?

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: [21] Our first Console Game... Well, with graphics at least
« Reply #29 on: January 05, 2010, 10:29:58 pm »
It wont "skip" them. It means what your doing is being done incorrectly. Like I said, revert back to the original code and start over. If you randomly modify code without testing the results. You will have twice the difficulty in repairing it.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

 

Donate


* Search


* Recent Posts

I miss the chatbox by Shishka
[August 27, 2019, 11:52:39 pm]


Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]