Beispiel #1
0
global void ScrollMap(int vel,unsigned char course)
{
        int vel_x=0,vel_y=0;
        switch(course) {
        case MOVE_UP:
                vel_y=vel;
                ClearScreen();
                break;
        case MOVE_DOWN:
                break;
                vel_y=-vel;
                ClearScreen();
        case MOVE_RIGHT:
                vel_x=vel;
                ClearScreen();
                break;
        case MOVE_LEFT:
                vel_x=-vel;
                ClearScreen();
                break;
        case NOT_MOVE:
                break;
        }
        MoveMap(vel_x,vel_y);
}
Beispiel #2
0
void Map::DramMap()
{
    int winWid,winHei;
    FsGetWindowSize(winWid,winHei);
    glRasterPos2d(0.0,(double)(winHei-1));
    
    unsigned char *p=png.rgba;
    int i,j;
    
    
    
    beginx=midpointx-m/2;
    beginy=midpointy-n/2;
    
	char *pp = new char[800*600*4];
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            
            pp[(i*m+j)*4]=p[((i+beginy)*png.wid+j+beginx)*4];
            pp[(i*m+j)*4+1]=p[((i+beginy)*png.wid+j+beginx)*4+1];
            pp[(i*m+j)*4+2]=p[((i+beginy)*png.wid+j+beginx)*4+2];
            pp[(i*m+j)*4+3]=p[((i+beginy)*png.wid+j+beginx)*4+3];
        }
        
    }
    
    glDrawPixels(m,n,GL_RGBA,GL_UNSIGNED_BYTE,pp);
    MoveMap();
	
	delete [] pp;
    
}
Beispiel #3
0
enum ActionMenu StageMain(int *stageState, char *mapName)
{
    static int bgm = - 1;
    static char name[MAX_PATH];
    
    switch (*stageState) {
    case 0:
        map = ReadMap(mapName);
#if !MAP_EDIT_MODE
        GetBgmName(name, mapName);
        bgm = LoadSound(name);
#endif        
        *stageState = 1;
        break;

    case 1:
        {
            InitMap(map);
            CreateObject(map);
            DrawMain = StageDraw;
            LoopSound(bgm);
            *stageState = 2;
        }
        break;

    case 2:
            MoveMap(map);
            MoveEnemy(map);
            MoveItem(map);
            MoveBomb(map);
            MoveEnemy(map);
            MovePlayer(map);
            if (IsPlayerDie()) {
                SoundPlay(res.sound_die);
                life--;
                if (life < 0) {
                    FreeStage(map, stageState, bgm);
                    return MENU_GAMEOVER;
                }
                *stageState = 1;
            }
            if (IsPlayerClear()) {
                FreeStage(map, stageState, bgm);
                return MENU_CLEAR;
            }
            break;
    }
    return MENU_STAGE;
}
Beispiel #4
0
void CreateObject(Map *map)
{
    int i;

    InitEnemy();
    InitItem();
    InitBomb();
    InitEffect();
    for (i = 0; i < map->objectNum; i++) {
        float x = (float)map->object[i].x * BLOCK_WIDTH;
        float y = (float)map->object[i].y * BLOCK_HEIGHT;
        char type = map->object[i].type;
        int r;
        if (type == PLAYER) {
            InitPlayer(x, y);
        }
        r = CreateEnemy(type, x, y);
        if (r) {
            continue;
        }
        CreateItem(type, x, y);
    }
    MoveMap(map);
}    
Beispiel #5
0
void CCamera::Update(D3DXVECTOR2 _pos, D3DXVECTOR2 _velloc)
{
	if (_velloc == D3DXVECTOR2(0,0) || g_IsMoving) 
		return;
	if (curIndex == m_countPoint-1) {
		m_pos.x = m_arrayPoint[curIndex].x - WIDTH_SCREEN/2;

		if (CPLayingGameState::g_Stage==3) //cheat 
			{
				m_pos.x += 10;
				m_pos.y =  m_arrayPoint[curIndex].y + HEIGHT_SCREEN/2;
			}
		goto updateViewport;
		return;
	}
	{
		POINT rPos = {_pos.x , _pos. y};
		//X
		if (_velloc.x != 0) {
			POINT pCur = m_arrayPoint[curIndex];

			bool isHaveNextX = (curIndex < m_countPoint -1) & (pCur.y == m_arrayPoint[curIndex+1].y);
			bool isHavePreX = (curIndex > 0) & (pCur.y == m_arrayPoint[curIndex-1].y);
			bool isNextMiddleX = false;
			GetMiddlePoint(curIndex + 1, &isNextMiddleX, NULL);
			bool isCurMiddleX = false;
			GetMiddlePoint(curIndex, &isCurMiddleX, NULL);

			if (isNextMiddleX || (isHaveNextX && curIndex==m_countPoint-2)) { 
				m_indexMoveTo = curIndex + 1; m_DirectMove = DIRECT_X;
			}

			if (_velloc.x > 0 && isHaveNextX) {
				int boundX = isNextMiddleX ? m_arrayPoint[curIndex + 1].x - WIDTH_SCREEN / 2 : m_arrayPoint[curIndex + 1].x;
				int temp = isCurMiddleX ? pCur.x + WIDTH_SCREEN/2 : pCur.x;

				if (rPos.x > temp && rPos.x < boundX) {
					m_pos.x = (float)_pos.x - WIDTH_SCREEN/2;
				}

				if (rPos.x > m_arrayPoint[curIndex + 1].x) {
					curIndex = curIndex + 1;
				}
			} else {
				if (_velloc.x < 0) {
					if ((isHavePreX && curIndex != m_countPoint-1) || isCurMiddleX) {
						if (rPos.x < pCur.x) {
							curIndex = curIndex -1;
						}
						if (isCurMiddleX) {
							if (rPos.x > pCur.x + WIDTH_SCREEN/2) {
								m_pos.x = (float)_pos.x - WIDTH_SCREEN/2;
							}
						}

					} else {
						int boundX = isNextMiddleX ? m_arrayPoint[curIndex + 1].x - WIDTH_SCREEN / 2 : m_arrayPoint[curIndex + 1].x;
						if (rPos.x > pCur.x && rPos.x < boundX && curIndex != m_countPoint-1) {
							//update
							m_pos.x = (float)_pos.x - WIDTH_SCREEN/2;
						}
					}
				}
			}
		}


		//Y
		if (_velloc.y != 0) {
			int nextIndexY = GetNextIndexY(rPos, _velloc.y);

			if (nextIndexY != -1) {
				if (_velloc.y > 0 && m_arrayPoint[nextIndexY].y - m_arrayPoint[curIndex].y < HEIGHT_SCREEN && !m_curIsBoundY) {
					curIndex = nextIndexY;
					nextIndexY = GetNextIndexY(rPos, _velloc.y);
				}

				char dirY = _velloc.y > 0 ? 1 : -1;
				long offsetY =  m_curIsBoundY ? HEIGHT_SCREEN / 2 + OFFSET_MAP_Y : 0;
				long temp = _velloc.y > 0 ? m_arrayPoint[curIndex].y + HEIGHT_SCREEN + OFFSET_MAP_Y - offsetY : m_arrayPoint[curIndex].y - offsetY;
				if ((_velloc.y < 0 ||_velloc.y > 0 && CRockman::m_IsClimbing) && _pos.y * dirY > (temp)* dirY) {
					if ((m_pos.x - m_arrayPoint[curIndex].x - WIDTH_SCREEN / 2) < 10) {
						m_indexMoveTo = nextIndexY;
						m_DirectMove = DIRECT_Y;
						MoveMap();
						return;
					}
				}
			}
		}
	}
updateViewport:
	m_viewPort.left = m_pos.x;
	m_viewPort.right = m_viewPort.left + WIDTH_SCREEN;
	m_viewPort.top = m_pos.y;
	m_viewPort.bottom =m_viewPort.top - HEIGHT_SCREEN;

	g_PosCamera = m_pos;
}
Beispiel #6
0
//---------------------------------------------------------------------------
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
  PAINTSTRUCT ps;
  HDC hdc;
  switch(msg)
  {

    case WM_LBUTTONUP : // mouse left button down
    {
      mouse.x = (int)LOWORD(lparam) ;
      mouse.y = (int)HIWORD(lparam) ;
      mouse.button = mouse_LEFT ;
      if((world->building[mouse.cell_x][mouse.cell_y]).type!=building_type_NO)
      {
        HiveElements->action=action_BUILDING_CLICK ;
        HiveElements->param[0]=mouse.cell_x;
        HiveElements->param[1]=mouse.cell_y;
      } ;
      return 0 ;
    }break ;
    case WM_RBUTTONUP : // mouse right button down
    {
      mouse.x = (int)LOWORD(lparam) ;
      mouse.y = (int)HIWORD(lparam) ;
      mouse.button = mouse_RIGHT ;
    }return 0;break ;
    case WM_MOUSEMOVE :
    {
      mouse.x = (int)LOWORD(lparam) ;
      mouse.y = (int)HIWORD(lparam) ;
      mouse.cell_x = (mouse.x>>5)+(world->player[player_ID]).current_x_screen ;
      mouse.cell_y = (mouse.y>>5)+(world->player[player_ID]).current_y_screen ;
      if((world->building[mouse.cell_x][mouse.cell_y]).type==building_type_NO &&
         (world->building[mouse.cell_x][mouse.cell_y]).territory[player_ID]==1)
        mouse.y_frame=building_y_frame_GOODPLACE;
      else
        mouse.y_frame=building_y_frame_BADPLACE;
     /* int button=(int)wparam ;
      if(button & MK_LBUTTON)
        mouse.button=mouse_LEFT ;
      else
      if(button & MK_RBUTTON)
        mouse.button=mouse_RIGHT ;*/
    } ;
    return 0;break;
    case WM_CHAR ://ascii - wparam, key state - lparam
    {
      switch(wparam)
      {

        case 27:
                PostMessage(main_handle,WM_QUIT,0,0) ;  //if ESC is down
                app_run=0;
                break;
        case '8' :  //  MOVE MAP UP
          MoveMap((world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen,0,-1);
        break;
        case '2' :  //  MOVE MAP DOWN
          MoveMap((world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen,0,1);
        break;
        case '4' :  //  MOVE MAP LEFT
          MoveMap((world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen,-1,0);
        break;
        case '6' :  //  MOVE MAP RIGHT
          MoveMap((world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen,1,0);
        break ;
      } ;
      return 0;
    }break;
    case WM_CREATE :
    {
      return 0 ;
    }break ;
    case WM_PAINT  :
    {
      hdc=BeginPaint(hwnd,&ps) ;
      EndPaint(hwnd,&ps) ;
      return 0 ;
    }break ;
    case WM_DESTROY:
    {
      PostQuitMessage(0) ;
      app_run = 0;
      return 0 ;
    }break ;
    default:break;
  } ;//end switch
  return(DefWindowProc(hwnd,msg,wparam,lparam)) ;
};//end WinProc