-
.
Forse ma dico forse riesco -
.
Appassionato di musica non potevo non postarvi questo topic. Girando per la rete si legge di Lame Encoder (chi usa Windows ed in particolare per convertire lo conosce senz'altro) come il miglior encoder per codificare/decodificare i file wave per convertirlo in mp3.
Ma dov'è il problema?
Il problema sta nel fatto che il Lame Encoder per sistemi x64 non è facilmente trovabile (anche se ho 2 link), ma il vero problema ( ) è per chi lo usa per la programmazione! Chi progetta convertitori di musica (come me, che posterò tra poco) smadonna un pò, dato che le dll non sono compatibili con il .Net .
Ed ecco la soluzione!
Un programmatore vecchio come il suo encode che ho trovato (2004), non si sa come, ma è compatibile con il .Net!!!
Si lo so, posso sembrare pazzo, ma quando posterò il mio progetto vi renderete conto che non stavo scherzando. Per fortuna questo encode è open source e non è toccato dal 2005.
Non mi ricordo l'esatta pagina dove trovai questo encoder, però ne ho trovata un'altra con la versione più recente:
www.free-codecs.com/download/bladeenc.htm
Spero vi sarà utile.
<---- Questa sarà la risposta di molti di voi LOL -
.
Appena ci saranno minimo 5 iscritti, inizieremo il contest. Attendo -
.
Io aggiungerei il mio, cioè il DELL INSPIRON 15R, l'ho pagato 500 euro ed ha delle prestazioni fantastiche. Monta Core Intel i5 quello di base, se volete spendere 50 euro in più c'è anche l'i7. Inoltre monta Windows 7 x64 ed ha la licenza inclusa di McAfee, il migliore antivirus a pagamento (dopo Kaspesky ovviamente) Insomma poi ci sono tantissime altre cose. Cercatelo con google, è fantastico. Ovviamente io sto scrivendo da questo pc. -
.
secondo me il transformer prime è l'unico che può competere!
poi non so gli altri tablet, ma la batteria dell ipad dura moltissimo anche con un utilizzo intensivo -
.
-
.
1 CONTEST GRAFICO UFFICIALE
Tempo: 3 giorni
Premio: Targhetta personalizzata o avatar o Skin per forum fatta da me (MatrixNet)Cosa si deve fare per vincere il contest:
Creare un'immagine non più grande di 500x200 px che rappresenti al meglio l'informatica. Potrete inserire nell'immagine ciò che vi pare e piace (esempio: computer, persone importanti nell'informatica, codici... ecc...). Insomma, tirate fuori il meglio di voi grafici in questo lavoro!Su cosa verrà fatta la votazione:
La votazione avverrà appena finito il contest con i seguenti parametri:- Ordine
- Qualità
- Originalità
- Effetti
I voti saranno da 1 a 10 per tutti i parametri. Colui che avrà alla fine il punteggio più alto vincerà.
p.s: Si possono presentare massimo 2 lavori a testa -
.
No, sono indirizzi Torrent, perciò devi utilizzare un client Torrent. Ti consiglio di scaricare uTorrent. Automaticamente il file che hai scaricato si aprirà con uTorrent ed inizierà il download del gioco -
.
ciao a tutti mi chiamo riccardo e ho 12 anni .
questo per me e il forum piu superpazzescamenteentebello e informato e utile -
.
Non credo che per grafica si intende solo disegni fatti via software di manipolazione grafica.
Ma penso che la grafica sia qualcosa fatta da noi... Con le mani!
Appena finito di fare un disegnino!
Ecco a voi !
Ditemi cosa se pensate : -
.
Avete il jailbreack e non volete perderlo per nessuna ragione?
È nato su cydia un nuovo tweak, che disabilita i tasti "Ripristina impostazioni" e “Cancella contenuto ed impostazioni” presenti in "Impostazioni > Generali"
Il tweak è presente nella repo di BigBoss ed è gratuito. -
.
Salve ragazzi , siete stanchi dei badges che appaiono su AppStore e Cydia quando non aggiornate qualcosa?
Bene , su cydia, nella repo di bigboss Sono uscite due nuovi tweak ; No AppStore Badges e No Cydia Badges.
E possibile utilizzare questi due tweak anche da MobileTerminal , dando i comandi :per No Badges AppStoreCODICENASB
Eper No cydia BadgesCODICENCB -
.
Online ho trovato un buonissimo source per creare uno snake game da console: CODICEmisc.cs:
using System;
// Author: Francis Rowe
// This software is public domain. Enjoy.
// Version: 1.0
namespace sharp_snake
{
public class misc
{
// Colour information:
public static ConsoleColor colWalls = ConsoleColor.Black; // this is also the snake color
public static ConsoleColor colApples = ConsoleColor.DarkRed;
public static ConsoleColor colGrid = ConsoleColor.White;
public static ConsoleColor colWindow = ConsoleColor.Black;
// Controls the speed of the snake (global because it is set on main menu too)
public static int iWaitTime = 59;
// Write a string from a given position, with a given background color
public static void voDrawForm(ConsoleColor colInBackGround, int iInXPos,
int iInYPos, string strInMessage)
{
Console.BackgroundColor = colInBackGround;
Console.SetCursorPosition(iInXPos, iInYPos);
Console.Write("{0}", strInMessage);
return;
}
// Print "SHARP SNAKE" in big text at the bottom of the screen
public static void voDrawTitle(ConsoleColor colInWindow, ConsoleColor colInGrid)
{
// Monochrome bitmap, created by hand :)
byte[] bytearcMono = new byte[]
{
0x3f, 0x66, 0xfd, 0xfb, 0xf0, 0x0f, 0xd9, 0xbf, 0x66, 0xfc,
0x3f, 0x66, 0xfd, 0xfb, 0xf0, 0x0f, 0xd9, 0xbf, 0x6e, 0xfc,
0x30, 0x66, 0xcd, 0x9b, 0x30, 0x0c, 0x19, 0xb3, 0x7c, 0xc0,
0x30, 0x66, 0xcd, 0x9b, 0x30, 0x0c, 0x1d, 0xb3, 0x78, 0xc0,
0x3f, 0x7e, 0xfd, 0xfb, 0xf0, 0x0f, 0xdf, 0xbf, 0x70, 0xfc,
0x3f, 0x7e, 0xfd, 0xfb, 0xf0, 0x0f, 0xdf, 0xbf, 0x70, 0xfc,
0x03, 0x66, 0xcd, 0xe3, 0x00, 0x00, 0xdf, 0xb3, 0x78, 0xc0,
0x03, 0x66, 0xcd, 0xf3, 0x00, 0x00, 0xdb, 0xb3, 0x7c, 0xc0,
0x3f, 0x66, 0xcd, 0xbb, 0x00, 0x0f, 0xd9, 0xb3, 0x6e, 0xfc,
0x3f, 0x66, 0xcd, 0x9b, 0x00, 0x0f, 0xd9, 0xb3, 0x66, 0xfc
};
// Output the bitmap as coloured text:
Console.SetCursorPosition(0, 36);
Console.ForegroundColor = colInGrid; //gridCol;
ConsoleColor[] c = new ConsoleColor[] { colInWindow, colInGrid };
for (int iOrgScope = 0; iOrgScope < bytearcMono.Length; iOrgScope++)
for (int iOrgScopeLow = 7; -1 < iOrgScopeLow; iOrgScopeLow--)
voDrawForm(colInWindow, Console.CursorLeft, Console.CursorTop, (new string[] { " ", "O" })[1 & (bytearcMono[iOrgScope] >> iOrgScopeLow)]);
Console.SetCursorPosition(20, 47);
Console.ForegroundColor = ConsoleColor.Magenta;
Console.BackgroundColor = colWindow;
Console.Write("A snake game written in C#");
return;
}
// Print the game instructions onto the right of the screen
public static void voPrintInstructions()
{
Console.ForegroundColor = ConsoleColor.DarkGray;
string[] strarcOrgLocal = new string[]
{
"PAUSE (Esc)",
"",
"KILL SNAKE (K)",
"",
"FULLSCREEN (Alt+Enter)"
};
int iOrgIndex = 0;
for (int iOrgScope = 0; strarcOrgLocal.Length > iOrgScope; iOrgScope++)
{
voDrawForm(colWindow, 12 + iOrgIndex + 8, 33, strarcOrgLocal[iOrgScope]);
iOrgIndex += strarcOrgLocal[iOrgScope].Length + 2;
}
return;
}
}
}
menu.cs:
using System;
// Author: NightCrawlerO3X
// This software is public domain. Enjoy.
namespace sharp_snake
{
class menu : misc
{
// Specifies where the menu should be drawn from.
static int iXPos, iYPos;
// Stores all the menu strings
static string[] strarcMenu;
// Stores the index that is currently in focus
static int iIndex;
// Initialize the menu
public menu(string[] strarcInMenu, int iInWordLength, int iInXPos, int iInYPos)
{
iIndex = 0;
strarcMenu = strarcInMenu;
// Make sure that all strings are no
// longer than the maximum length specified
for (int iOrgScope = 0; strarcMenu.Length > iOrgScope; iOrgScope++)
{
if (iInWordLength < strarcMenu[iOrgScope].Length)
{
string strOrgScope = "";
for (int iOrgScopeLow = 0; iInWordLength > iOrgScopeLow; iOrgScopeLow++)
strOrgScope += strarcMenu[iOrgScope][iOrgScopeLow];
strarcMenu[iOrgScope] = strOrgScope;
}
}
iXPos = iInXPos;
iYPos = iInYPos;
return;
}
// Set a new focus for the current index
private static void voSetFocus(ConsoleColor colInFocus)
{
Console.ForegroundColor = ConsoleColor.White;
voDrawForm(colInFocus, iXPos, iIndex + iYPos, strarcMenu[iIndex]);
}
// Make a menu selection choice
public static int iThisSelect()
{
for (iIndex = 0; strarcMenu.Length > iIndex; iIndex++)
voSetFocus(0 == iIndex ? ConsoleColor.Blue : ConsoleColor.Gray);
for (iIndex = 0; ; iIndex |= 0 )
{
keyboard.flushInputStream(keyboard.no_op); // flush input
keyboard.pollInputStream(keyboard.nextKey); // wait for new input
switch (keyboard.currentInput)
{
case ConsoleKey.Enter: return iIndex; // the user confirmed their choice, we return the index
case ConsoleKey.DownArrow: voSetFocus(ConsoleColor.Gray); iIndex += 1; break;
case ConsoleKey.UpArrow: voSetFocus(ConsoleColor.Gray); iIndex -= 1; break;
}
iIndex = (strarcMenu.Length == iIndex) ? 0 : (0 > iIndex ? strarcMenu.Length - 1 : iIndex);
voSetFocus(ConsoleColor.Blue); // set outline focus on new index
}
throw
new Exception("menu.cs, Err, iThisSelect(): UNKNOWN ERROR HAS OCCURED");
}
}
}
main.cs:
using System;
// Author: NightCrawlerO3X
// This software is public domain. Enjoy.
namespace sharp_snake
{
// TO implement (essential game-related features):
// implement obstacle courses; special maps with walls inside the grid, creating a maze-like structure
// implement a "golden apple" that appears on random occasions and remains on the screen for 8 seconds. When eaten, the apple counter goes up by 10, not 1. Remember, *golden* apple it is.
// An AI that will automatically play a game of snake; use djikstra's algorithm to find the shortest path with each move. However, I must check that the snake can exit safely after the move.
// anything else is just mental masturbation
class main : misc
{
// Create an object for a user input menu.
static menu gm = new menu(new string[] { "Play (with walls)", "Play (without walls)", "Quit",
"Change difficulty: VERY EASY",
"Change difficulty: EASY",
"Change difficulty: NORMAL",
"Change difficulty: HARD",
"Change difficulty: VERY HARD"}, 28, 1, 3);
public static void Main(string[] args)
{
Console.CursorVisible = false;
Console.SetWindowSize(80, 50);
// Object of the entire game environment
CLIinterface game;
for (; ; )
{
// Set the window to it's default background color
Console.BackgroundColor = colWindow;
Console.Clear();
// Instruct the user how to use the menu menu.
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write("Use the UP/DOWN arrow keys on your keyboard to navigate the menu.\n" +
"To confirm your choice, press Enter.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
" Written by NightCrawler03X.\n" +
" >This program and it's source code belong in the public domain.\n" +
" >Use them however you wish.\n\n" +
" >If you use Windows XP, use ALT+Enter to get fullscreen.\n" +
" >(it doesn't always work on Vista/7)\n\n" +
" >Set the font to 12x16 raster for best results. Do this by right\n" +
" >clicking the window title and going on properties.\n\n" +
" >NOTE: Changing difficulty just means changing the default speed.");
voDrawForm(colWindow, 20, 47, "A snake game written in C#.");
voDrawTitle(colWindow, colGrid); // Draw "SHARP SNAKE" in big letters
int x = menu.iThisSelect(); // Get user input from main menu.
if (2 == x) // Apparently the user got bored of my snake game.
{
Console.ForegroundColor = ConsoleColor.White;
voDrawForm(ConsoleColor.Red, 12, 16, "ARE YOU SURE !?!? PRESS 'Y' TO QUIT, 'N' TO CONTINUE");
keyboard.pollInputStream(keyboard.ynConfirm);
if (ConsoleKey.Y == keyboard.currentInput) return;
continue;
}
if (2 < x) // Change game difficulty setting
{
int[] speed = new int[] { 100, 80, 60, 40, 20 };
iWaitTime = speed[x - 3];
Console.ForegroundColor = colGrid;
voDrawForm(ConsoleColor.Red, 12, 16, "DIFFICULTY LEVEL CHANGED!");
System.Threading.Thread.Sleep(800);
continue;
}
// Initialize the game environment, then begin
game = new CLIinterface(0 == x);
game.voStart();
continue;
}
}
}
}
keyboard.cs:
using System;
// Author: NightCrawlerO3X
// This software is public domain. Enjoy.
namespace sharp_snake
{
public class keyboard : misc
{
// Used globally to store a current input from the stream
public static ConsoleKey currentInput;
// POLL for input until interrupted
public static void pollInputStream(oPtr pk)
{ for (; ; ) if (pk.Invoke(Console.ReadKey(true).Key)) break; }
// FLUSH input stream, stopping if interrupted
public static void flushInputStream(oPtr pk)
{ for (; Console.KeyAvailable; ) if (pk.Invoke(Console.ReadKey(true).Key)) break; }
// The following are functions that can be used by the two functions above:
// FLUSHING
// This is used with flushInputStream to stop flushing when there is new non-duplicate input
public static bool verifyNonDuplicateKey(ConsoleKey tmp)
{ return tmp != currentInput ? tmp == (currentInput = tmp) : false; }
// FLUSHING
// This is used to flush the entire stream
public static bool no_op(ConsoleKey tmp) { return false; }
// Used to refer to one of the two above functions
public delegate bool oPtr(ConsoleKey c);
// POLLING; simply set currentInput to the next key available
public static bool nextKey(ConsoleKey tmp) { currentInput = tmp; return true; }
// POLLING
// Set ck to given input, and return true if Y/N, false if not
public static bool ynConfirm(ConsoleKey tmp)
{ return ((ConsoleKey.N == (currentInput = tmp)) || (ConsoleKey.Y == currentInput)); }
// POLLING
// Set ck to given input, and return true if Esc was pressed, false if not
public static bool escConfirm(ConsoleKey tmp)
{ return ConsoleKey.Escape == tmp; }
}
}
snake.cs:
// Author: NightCrawlerO3X
// This software is public domain. Enjoy.
using System;
namespace sharp_snake
{
class snake
{
public struct coord
{
public int x, y, direction;
} // x/y coordinates (plus direction)
public coord[] coordarcBody; // Stores the positions and directions of each part of the snake
// Custom settings
private bool m_bWalls; // if there are walls surrounding the grid
private bool m_bAlive; // if the snake is alive in it's current state
// Store the current direction of the front of the snake
private int m_iDirection; // (0 left, 1 down, 2 right, 3 up)
// Instances of this are used to refer to events.
private delegate void ptr();
// Used to indicate the current position of the apple
private coord m_coordApple;
// Used to indicate how many apples the snake has currently eaten
private int m_iAppleCount;
// Not actually a co-ord, it is just conveniently used to store the dimensions of the grid
private coord coordGrid;
// Used to control events in the game
private ptr[,] ptrmatrixEvents;
// Used when moving the snake up or left
private void voMoveNorthWest(ref int p, int q)
{
if (0 > (p -= 1))
{
m_bAlive = !m_bWalls;
p = q - 1;
}
return;
}
// Used when moving the snake down or right
private void voMoveSouthEast(ref int p, int q)
{
if (0 == (p = (p + 1) % q))
m_bAlive = !m_bWalls;
return;
}
// EVENT: Move the snake left
private void m_voMoveLeft()
{
voMoveNorthWest(ref coordarcBody[coordarcBody.Length - 1].x, coordGrid.x);
return;
}
// EVENT: Move the snake up
private void m_voMoveUp()
{
voMoveNorthWest(ref coordarcBody[coordarcBody.Length - 1].y, coordGrid.y);
return;
}
// EVENT: Move the snake down
private void m_voMoveDown()
{
voMoveSouthEast(ref coordarcBody[coordarcBody.Length - 1].y, coordGrid.y);
return;
}
// EVENT: Move the snake right
private void m_voMoveRight()
{
voMoveSouthEast(ref coordarcBody[coordarcBody.Length - 1].x, coordGrid.x);
return;
}
// DO NOTHING (when the snake moves in free space)
private void voNop()
{
return;
}
// Kill the snake
private void voGameOver()
{
m_bAlive = false;
return;
}
// Generate a new apple
// Update the apple counter with a given value
private void voGenerateApple(int count)
{
System.Random number;
new_apple:
number = new System.Random();
m_coordApple.x = number.Next(coordGrid.x);
m_coordApple.y = number.Next(coordGrid.y);
// Make sure the apple was not generated inside the snake.
// If it was, generate a new apple, again.
for (int i = 0; i < coordarcBody.Length; i++)
if (m_coordApple.x == coordarcBody[i].x && m_coordApple.y == coordarcBody[i].y) goto new_apple;
// Apple was generated outside the snake. Now continue.
ptrmatrixEvents[m_coordApple.x, m_coordApple.y] = voEatApple;
m_iAppleCount = count;
return;
}
// EVENT: The snake has eaten an apple, so increment the counter and generate a new apple
private void voEatApple() // generates a new apple position outside of the snake, removing the old apple
{
// Generate a random position for the new apple:
ptrmatrixEvents[m_coordApple.x, m_coordApple.y] = voNop;
voGenerateApple(++m_iAppleCount); // Generate a new apple, after discarding the old one, and increment the apple counter
// Set the previous back of the snake to game over
// Since the snake should grow by one when it had eaten the apple.
ptrmatrixEvents[coordPrevBack.x, coordPrevBack.y] = voGameOver;
// Grow the snake by one, placing the new cell on it's rear:
coord[] coordOrgLocal = coordarcBody; // Create backup of body
coordarcBody = new coord[coordarcBody.Length + 1]; // Resize body (this discards all previous data)
// Restores the old data in body, but moved one to the right
for (int j = 1; j < coordarcBody.Length; j++)
coordarcBody[j] = coordOrgLocal[j - 1];
coordarcBody[0] = coordPrevBack; // Restore the coord for the previous back of the snake
return;
}
// Used to store the previous back of the snake, for when eating an apple
// Because the previous back needs to be redrawn when that happens.
private coord coordPrevBack = new coord();
// (Automatic) EVENT: Move the snake.
// This is used when the UPDATE(int direction) function is called externally.
private void voSnakeMove()
{
// This stops the apple from pointing to
// nop if it is generated inside the snake.
ptrmatrixEvents[m_coordApple.x, m_coordApple.y] = voEatApple;
// Make a copy of the back of the snake in case it eats an apple
coordPrevBack = coordarcBody[0];
ptrmatrixEvents[coordarcBody[0].x, coordarcBody[0].y] = voNop; // the back of the snake no longer occupies this space after the move, so it should be made safe to move there
// Move all snake body parts forward in the given direction. The front of the snake stays the same
for (int i = 0; i < coordarcBody.Length - 1; i++)
coordarcBody[i] = coordarcBody[i + 1];
// Switch direction
switch (m_iDirection)
{
case 0:
this.m_voMoveLeft();
break;
case 1:
this.m_voMoveDown();
break;
case 2:
this.m_voMoveRight();
break;
case 3:
this.m_voMoveUp();
break;
default:
throw new Exception(
"snake.cs, Err, voSnakeMove(): this.m_iDirection, GREATER THAN 3, INVALID DIRECTION");
}
// Now that the snake'd head has moved, invoke the new event that it resides over.
ptrmatrixEvents[coordarcBody[coordarcBody.Length - 1].x, coordarcBody[coordarcBody.Length - 1].y].Invoke();
// Now set that to game over, because otherwise after the snake has moved by X times,
// where X is the length of the snake, it will no longer die when crashing
// into itself, thus making the game easy.
ptrmatrixEvents[coordarcBody[coordarcBody.Length - 1].x, coordarcBody[coordarcBody.Length - 1].y] = voGameOver; // Also, the snake would die it we did this first rather than second
// Set the direction of the snake's head to the direction it actually just travelled.
coordarcBody[coordarcBody.Length - 1].direction = m_iDirection;
return;
}
// Initialize the snake, and the game environment.
public snake(bool walls)
{
m_iDirection = 2; // Snake moves right by default
m_bWalls = walls; // Set the "walls" option.
m_bAlive = true; // Set the snake to alive
coordGrid.x = (coordGrid.y = 30) + 18; // Set the dimensions of the grid.
// Initialize the event grid, based on the dimensions we just set.
ptrmatrixEvents = new ptr[coordGrid.x, coordGrid.y];
// All parts of the grid point to empty events by default.
for (int x = 0; x < coordGrid.x; x++)
for (int y = 0; y < coordGrid.y; y++) ptrmatrixEvents[x, y] = voNop;
coordarcBody = new coord[25]; // Snake is 25 cells long by default
// Set the positions of each part of the snake.
// The snake faces right from the top left of the grid by default.
for (int i = 0; i < coordarcBody.Length; i++)
{
coordarcBody[i].y = 0;
coordarcBody[i].x = i;
coordarcBody[i].direction = 2; // they all represent the right arrow by default, since that's the snake's initial direction
}
// Set all events in the part of the grid
// that the snake covers, so that they are game-over events.
for (int x = 0; x < coordarcBody.Length - 1; x++) ptrmatrixEvents[x, 0] = voGameOver;
voGenerateApple(0); // Generate an apple, and initialize the counter
return;
}
private void voSwitchLeft()
{
m_iDirection = 2 != m_iDirection ? 0 : m_iDirection;
return;
}
private void voSwitchDown()
{
m_iDirection = 3 != m_iDirection ? 1 : m_iDirection;
return;
}
private void voSwitchRight()
{
m_iDirection = 0 != m_iDirection ? 2 : m_iDirection;
return;
}
private void voSwitchUp()
{
m_iDirection = 1 != m_iDirection ? 3 : m_iDirection;
return;
}
// Update the current state based on new input.
public void voThisUpdate(int iInDirection)
{
// Change direction of the snake, according to input
switch (iInDirection)
{
case 0:
this.voSwitchLeft();
break;
case 1:
this.voSwitchDown();
break;
case 2:
this.voSwitchRight();
break;
case 3:
this.voSwitchUp();
break;
// Left, down, right, up. Ever played GTA?
default:
throw new Exception(
"snake.cs, Err, voThisUpdate(iInDirection): iInDirection, INVALID (HIGHER THAN 4)");
}
if (m_bAlive)
voSnakeMove();
return;
}
// The following are properties used externally to display the snake environment.
public bool bThisWalls
{
get
{
return m_bWalls;
}
} // Reveal whether the grid is surrounded by a wall
public bool bThisAlive
{
get
{
return m_bAlive;
}
} // report whether or not the snake is alive
public int iThisXGrid
{
get
{
return coordGrid.x;
}
} // report the x dimension of the grid
public int iThisYGrid
{
get
{
return coordGrid.y;
}
} // report the y dimension of the grid
public int iThisApplesEaten
{
get
{
return m_iAppleCount;
}
} // report how many apples have been eaten
public int iThisAppleXPos
{
get
{
return m_coordApple.x;
}
} // report the x coord of the apple
public int iThisAppleYPos
{
get
{
return m_coordApple.y;
}
} // report the y coord of the apple
public int iThisSnakeLength
{
get
{
return coordarcBody.Length;
}
} // Return the snake's length
public int[] iarcThisSnakeDirections
{
get
{
return new int[]
{
coordarcBody[0].direction,
coordarcBody[coordarcBody.Length - 1].direction
};
}
}
public int[] iarcThisSnakeParts
{
get
{
return new int[]
{
coordarcBody[0].x,
coordarcBody[0].y,
coordarcBody[coordarcBody.Length - 1].x,
coordarcBody[coordarcBody.Length - 1].y
};
}
}
public int iThisDirection
{
get
{
return m_iDirection;
}
}
}
}
CLIinterface.cs:
using System;
// Author: NightCrawlerO3X
// This software is public domain. Enjoy.
namespace sharp_snake
{
class CLIinterface : misc
{
// Object of the snake class; this has the actual game data
private static snake snakeEnvironment;
// This stores the direction that the snake is going (0=left, 1=down, 2=right, 3=up, 4=turning point)
private static int iDirection;
// These are the characters used to indicate the snake's direction of movement.
private static int[] iarcDirChars = new int[]
{
27, 25, 26, 24, 79
};
// Draw the grid that the snake moves around in
private static void voDrawGrid()
{
for (int x = 0; snakeEnvironment.iThisXGrid > x; x++)
for (int y = 0; snakeEnvironment.iThisYGrid > y; y++)
voDrawForm(colGrid, x + 2, y + 2, " ");
return;
}
// If walls are to be drawn, draw them
private static void voDrawWalls()
{
if (!snakeEnvironment.bThisWalls) return;
Console.ForegroundColor = ConsoleColor.Blue;
for (int x = 0; x < snakeEnvironment.iThisXGrid; x++)
{
voDrawForm(colWalls, x + 2, snakeEnvironment.iThisYGrid + 2, "*"); // Draw horizontally
voDrawForm(colWalls, x + 2, 0 + 2 - 1, "*"); // Draw horizontally
}
for (int y = 0; y < snakeEnvironment.iThisYGrid; y++)
{
voDrawForm(colWalls, snakeEnvironment.iThisXGrid + 2, y + 2, "*"); // Draw vertically
voDrawForm(colWalls, 0 + 2 - 1, y + 2, "*"); // Draw vertically
}
// Err, draw others too
return;
}
private static void voDrawSnake()
{
int[] serialization = snakeEnvironment.iarcThisSnakeParts; // Get snake's positions
Console.ForegroundColor = colGrid;
for (int i = 0; i < snakeEnvironment.iThisSnakeLength; i++)
voDrawForm(colWalls, i + 2, 2, "" + (char)iarcDirChars[2]);
return;
}
// Initializes the screen, and the snake environment.
private static void redraw_environment(bool walls)
{
keyboard.flushInputStream(keyboard.no_op);
Console.CursorVisible = false;
Console.SetWindowSize(80, 50);
Console.BackgroundColor = colWindow;
Console.Clear();
voDrawTitle(colWindow, colGrid); // Print "SHARP SNAKE" in large letters
snakeEnvironment = new snake(walls); // Initialize game data, with or without walls
iDirection = snakeEnvironment.iThisDirection; // Get the default snake direction
// Draw the initial environment
voDrawGrid();
voDrawWalls();
voDrawSnake();
// Get the position of the apple, and draw it
voDrawForm(colApples, snakeEnvironment.iThisAppleXPos + 2,
snakeEnvironment.iThisAppleYPos + 2, " ");
// Report the default number of apples eaten, zero.
Console.ForegroundColor = colWalls;
// Initialize the counter displaying the number of apples eaten
voDrawForm(ConsoleColor.Cyan, 2, snakeEnvironment.iThisYGrid + 3,
"apples eaten: " + Convert.ToString(snakeEnvironment.iThisApplesEaten));
voPrintInstructions(); // Print the game's instructions.
return;
}
public CLIinterface(bool walls)
{
redraw_environment(walls);
return;
} // Constructor
private static bool handle_input() // Process user input, return false if input should stop being handled
{
ConsoleKey ck = keyboard.currentInput;
switch (ck)
{
case ConsoleKey.K:
return false; // Kill the snake
case ConsoleKey.LeftArrow:
iDirection = 2 == iDirection ? iDirection : 0;
break; // Move snake left
case ConsoleKey.DownArrow:
iDirection = 3 == iDirection ? iDirection : 1;
break; // Move snake down
case ConsoleKey.RightArrow:
iDirection = 0 == iDirection ? iDirection : 2;
break; // Move snake right
case ConsoleKey.UpArrow:
iDirection = 1 == iDirection ? iDirection : 3;
break; // Move snake up
// Pause the game:
case ConsoleKey.Escape:
Console.ForegroundColor = ConsoleColor.White;
voDrawForm(ConsoleColor.Red, 2, 35, "PAUSED, PRESS ESC AGAIN TO CONTINUE");
keyboard.flushInputStream(keyboard.no_op);
keyboard.pollInputStream(keyboard.escConfirm);
keyboard.currentInput = new ConsoleKey();
keyboard.flushInputStream(keyboard.no_op);
voDrawForm(colWindow, 2, 35, " ");
break;
default:
break;
}
return true;
}
// Sends a prompt to the snake to update itself, then draws the new snake as it is on the screen
private static void voUpdateEnvironment()
{
if (!snakeEnvironment.bThisAlive)
return;
// Before the move, get the body positions of the snake.
int[] serialized = snakeEnvironment.iarcThisSnakeParts;
// draw a white cell where the rear of the snake is
voDrawForm(colGrid, serialized[0] + 2, serialized[1] + 2, " ");
// In case the apple position changes
int p_xapple = snakeEnvironment.iThisAppleXPos, p_yapple = snakeEnvironment.iThisAppleYPos;
// Update the environment (data only; this won't update what's on the screen)
snakeEnvironment.voThisUpdate(iDirection);
// Now update what's on the screen:
// Get the new body positions of the snake
serialized = snakeEnvironment.iarcThisSnakeParts;
Console.ForegroundColor = colGrid; // For snake's arrows indicating directions
// Highlight the cell at the front of the snake
voDrawForm(colWalls, serialized[2] + 2, serialized[3] + 2,
"" + (char)iarcDirChars[snakeEnvironment.iarcThisSnakeDirections[1]]);
// placed outside to avoid the bug where sometimes the apple becomes invisible
voDrawForm(colApples, snakeEnvironment.iThisAppleXPos + 2,
snakeEnvironment.iThisAppleYPos + 2, " ");
// Redraw the apple onto the screen, if the apple's position changed.
if (snakeEnvironment.iThisAppleXPos != p_xapple
|| snakeEnvironment.iThisAppleYPos != p_yapple)
{
// Highlight the cell at the bakeyboard.ck of the snake
voDrawForm(colWalls, serialized[0] + 2, serialized[1] + 2,
"" + (char)iarcDirChars[snakeEnvironment.iarcThisSnakeDirections[0]]);
// Update the on-screen value reporting how many apples have been eaten
Console.ForegroundColor = colWalls;
voDrawForm(ConsoleColor.Cyan, 0 + 2, snakeEnvironment.iThisYGrid + 1 + 2,
"apples eaten: " + Convert.ToString(snakeEnvironment.iThisApplesEaten));
}
return;
}
public void voStart() // this is the main event loop used to control the game environment
{
for (; ; )
{
keyboard.currentInput = new ConsoleKey();
for (; snakeEnvironment.bThisAlive; )
{
keyboard.flushInputStream(keyboard.verifyNonDuplicateKey);
if (handle_input())
voUpdateEnvironment();
else
break;
System.Threading.Thread.Sleep(iWaitTime);
}
Console.ForegroundColor = ConsoleColor.White;
voDrawForm(ConsoleColor.Red, 7 + 2, 12 + 2,
"\n\nGAME OVER. Continue? [Y/N]. Press Y to continue, N to quit.");
keyboard.flushInputStream(keyboard.no_op);
keyboard.pollInputStream(keyboard.ynConfirm);
if (ConsoleKey.Y != keyboard.currentInput) return;
redraw_environment(snakeEnvironment.bThisWalls);
}
throw new Exception("CLIinterface.cs, Err, voStart(): UNKNOWN ERROR.");
}
}
}
Dentro al source ci sono vari file e spiegazioni. Enjoy It! It's open! -
.
Stanchi di avere una sola e piccola dock sul vostro iDevice?
Evan Lucas , ha creato e pubblicato su cydia l'applicazione DoubleDock che permette di avere due dock (una sopra l'altra) .
Il tweak è reperibile nella repo di bigboss a $0.99 -
.
Gran bel topic! (: