Home > other >  The Unity and development, based on practice course console map + player Demo
The Unity and development, based on practice course console map + player Demo

Time:09-23

Today saw a very good blog!
studio console map + player Demo

using System;

The namespace MyFirstGame
{
The class MainClass
{
Public static void Main (string [] args)
{
//when the game is about to start to do some operations
Const int mapW=46;//map width
Const int mapH=16;//height map

//define constants
Const int emptyTiledMap=0;//air brick
Const int TBTiledMap=1;//at the top and bottom brick
Const int LRTiledMap=2;//the two sides of the brick
Const int Player=3;//player


//game initializes the variable
Bool isOver=false;//end of the game
Int [and] mapData=https://bbs.csdn.net/topics/new int [mapH mapW];//map data
String [and] mapView=new string [mapH mapW];//map view

Int posW=1;//the location of the players in the W
Int his posH=1;//player in the position of the H

//initialize the map data
for (int i=0; i For (int j=0; J & lt; MapW; J++) {
//j will be initialized to an empty map brick
MapData [I, j]=emptyTiledMap;
//if the bricks at the side of the top or the bottom, is initialized to TBTiledMap
If (I==0 | | I==mapH - 1) {

MapData [I, j]=TBTiledMap;

} else if (j==0 | | j==mapW - 1) {
//if the bricks in the right or the left, is initialized to LRTiledMap
MapData [I, j]=LRTiledMap;

} else if (I==posW & amp; & J=={posH)
//the current position is players
MapData [I, j]=Player;

}
}
}
Code content can be more to doodle cottage blog http://blog.csdn.net/sinat_35761779/article/details/52239440

CodePudding user response:

Too basic, fundamental key useless to the unity of knowledge, has been written in c # in logic, feel more need not complicated logic (complex logic is very ugly, it will be very boring), but involves the unity knowledge (collision, animation, UI) demo, but learning, thanks for sharing!
  • Related