레이블이 Console-based Multiplayer Tetris Game인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Console-based Multiplayer Tetris Game인 게시물을 표시합니다. 모든 게시물 표시

2016년 5월 10일 화요일

4.2 Performance Upgrade - Completion


  • Previous Problem

Previous sources are ineffiently implemented about data send & receive.
If data is transfered by 'receive()' function, Host must wait until the host receive data.
So game'flow don't softly run.

Thus, I improved these sources as follows.

  • Improved Source
- change current socket option into non-blocking mode as using 'ioctlsocket(sock, FIONBIO, &sock_on)'
- server must wait as continuosly calling 'recevie()' function by the time opponent send data 
  
- change current socket option into non-blocking mode as using 'ioctlsocket(sock, FIONBIO, &sock_on)'



- I block what is calling send(), receive() funtions as using time. I renew opponent's data every second. Also, receive() function don't wait until opponent receive data. 

  • Result Screen (completed)





Console-based Multiplayer Tetris Game Project Completion




2016년 2월 16일 화요일

4.1 Time Function Addtion



  • 'showTime()' Function
---------------------------------------------------------------------------------
void showTime(void)
{
int newTime = time(NULL);
int diff = newTime - curTime;
point curPos;

if (sec < diff)
{
curPos = GetCurrentCursorPos();
sec = diff;

if (sec == 30 && !timeBlocking)
{
gameLevelUp();
timeBlocking = 1;
}
else if (sec == 60 && !timeBlocking)
{
curTime = time(NULL);
min++;
sec = 0;
gameLevelUp();
timeBlocking = 1;
}
else if(sec==31 || sec == 0)
timeBlocking = 0;

SetCurrentCursorPos(32, 10);
printf("   %02d : %02d    ", min, sec);

SetCurrentCursorPos(curPos.x, curPos.y);
}
}
---------------------------------------------------------------------------------

  •  add 'time.h' header file
        - Express time between 00:00 to 99:59 as using time(NULL)
  •  Whenever Time is flowing, Game Progress quicken once every 30s
         - It is controlled by 'timeBlocking' valuable whether 'gameLevelUp()' is called or not


Source Download (Github Repository)

2016년 1월 30일 토요일

3. Multiplay Implementation by UDP


  • Add library of 'ws2_32.lib'
  • Execution Sequence
      1. Server and Client information initialization
      2. Client send first data
      3. Tetris Game progressing
      4. if any one lose the game, first index data among sending array data is setting 'Lose Value'
      5. 'Lose User' send data and it close socket
      6. 'Win User' receive Array Data with 'Lose Value' of Opponent
      7. 'Win User' win with using 'Lose Value' of Opponent
      8. 'Win User' close socket

  • Reason 
      if 2 situation doesn't exist, Client'recv() function is blocking.
      if 4~7 situations don't exist, 'Win User' don't know the situation.

  • Next
      4.1 Speed up according to flowing time.
      4.2 Add score bettle system.
      4.3 Finally, I will upgrade quality and perfomance.

Source Download (Github Repository)

2016년 1월 26일 화요일

2. Tetris Implementation


  • Basic Tetris Game Implementation
  • Key-Operating Method 
       UP : Changes Block 
       DOWN : Goes down Block 
       LEFT : Move to the left
       RIGHT : Move to the right
       SPACE : Goes instantly down

  • Specialization Function
       Game Speed will increase by getting score.
       Next Block is indicated at small block board


Source Download (Github Repository)


references) 
책: C 프로그래밍 파워 업그레이드

2016년 1월 15일 금요일

1. Console-based Window API Informations Collection


  • Structure

COORD
 Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
https://msdn.microsoft.com/ko-kr/library/ms682119(v=VS.85).aspx
header file : windows.h

CONSOLE_CURSOR_INFO 
 Contains information about the console cursor.
https://msdn.microsoft.com/ko-kr/library/windows/desktop/ms682068(v=vs.85).aspx
header file : windows.h

CONSOLE_SCREEN_BUFFER_INFO
 Contains information about a console screen buffer.
http://msdn.microsoft.com/ko-kr/library/ms682093(v=VS.85).aspx
header file : windows.h



  • Function

GetStdHandle 
 Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
https://msdn.microsoft.com/ko-kr/library/ms683231
header file : windows.h

SetConsoleTextAttribue
 Sets the attributes of characters written to the console screen buffer by the WriteFile or WriteConsole function, or echoed by the ReadFile or ReadConsole function. This function affects text written after the function call.
https://msdn.microsoft.com/ko-kr/library/windows/desktop/ms686047(v=vs.85).aspx
header file : windows.h

SetConsoleCursorInfo
 Sets the size and visibility of the cursor for the specified console screen buffer.
https://msdn.microsoft.com/ko-kr/library/ms686019(v=VS.85).aspx
header file : windows.h

GetConsoleCursorInfo
 Retrieves information about the size and visibility of the cursor for the specified console screen buffer.
https://msdn.microsoft.com/ko-kr/library/windows/desktop/ms683163(v=vs.85).aspx
header file : windows.h


SetConsoleCursorPosition
 Sets the cursor position in the specified console screen buffer.
https://msdn.microsoft.com/ko-kr/ms686025
header file : windows.h

GetConsoleScreenBufferInfo
 Retrieves information about the specified console screen buffer.
https://msdn.microsoft.com/ko-kr/library/ms683171(v=VS.85).aspx
header file : windows.h

_kbhit()
 Checks the console for keyboard input.
https://msdn.microsoft.com/ko-kr/library/58w7c94c.aspx
header file : conio.h

_getch()
 Gets a character from the console without echo.
https://msdn.microsoft.com/ko-kr/library/078sfkak.aspx
header file : conio.h









Console-based Multiplayer Tetris Game Specifications

Console-based Multiplayer Tetris Game Specifications

  • IDE

       Visual Studio 2015


  • Language

       C


  • Configuration Management

       Git, SourceTree






  • Protocool
       UDP(User Datagram Protocol)

  • Development Order
       1. Console-based API Informations Collection
       2. Tetris Implementation
       3. Multiplay Implementation by UDP
       4. Quality and Performance Upgrade