Beispiel #1
0
/** ---------------------------------------------------------------------- **/
void GetString(int x, int y, char *Str, char *ViewStr)
{
	PosXY(x, y);
	PutString(x , y, ViewStr);
	PosXY(x + strlen(ViewStr), y);
	scanf("%s", Str);
	if(strlen(Str) < 1)
		printf("No Data Input\n\n");
}
Beispiel #2
0
PosXY getMouseDiff( PosXY Current , PosXY Old )
{
    
    PosXY MouseDiff( -(Old.X - Current.X), -(Old.Y -Current.Y) );
    
    if(abs(MouseDiff.X) > abs(MouseDiff.Y)) MouseDiff = PosXY( MouseDiff.X, 0 );
    else MouseDiff = PosXY( 0, MouseDiff.Y );
    
    return PosXY( MouseDiff.X/GLOBAL_WINDOW_WIDTH, MouseDiff.Y/GLOBAL_WINDOW_HEIGHT );
}
Beispiel #3
0
//	Arrow Key Test 
void GetImmString(int x, int y, char *Str)
{
	int	i;
	char	inpChar;
	char	inpStr[101];

	memset(inpStr, 0x00, 101);

	PosXY(x, y);

	for(i = 0; i < 20; i++)	{
		inpChar = getchar();
		if(inpChar == 0x0d || inpChar == 0x0a)
			break;
		inpStr[i] = inpChar;
		if(inpChar == '')	{
			inpChar = getchar();
			inpStr[i+1] = inpChar;
			i++;
		}
		printf("[%c], [%s]\n", inpChar, inpStr);
	}
	inpStr[i] = 0x00;

	strcpy(Str, inpStr);
}
Beispiel #4
0
bool Mine::p_Shoot()
{
  int x,y;
  PosXY (x,y);
  Add (x, y);

  return true;
}
Beispiel #5
0
BOOL FAR  MergeFile(LPSTR FileName, int view)
{
    HCURSOR hSaveCursor;
    char line[MAX_USER_LINE + 1];
    int offset; //Current offset of storage in block
    int lineLen; // length of line
    BYTE prevLength; //Previous line size
    LPVIEWREC v = &Views[view];
    WORD res;
    LPDOCREC d =&Docs[v->Doc];
    LPLINEREC pCurLine, pLastLine;
    LPBLOCKDEF pCurBlock, pNewBlock;
    long y;

    Assert( v->Doc >= 0);


    if ((hFileDoc = _lopen(FileName, OF_READ)) == HFILE_ERROR)
          return ErrorBox(ERR_File_Open, (LPSTR)FileName);

    if ((pszBufferDoc = DocAlloc(DISK_BLOCK_SIZE)) == NULL) {
        ErrorBox(SYS_Allocate_Memory);
        goto error1;
    }

    dwBytesReadDoc = DISK_BLOCK_SIZE;
    dwOffsetDoc = DISK_BLOCK_SIZE;
    lineLen = 0;

    //Delete selected text if any
    if (v->BlockStatus) {

        long XR, YR;

        GetBlockCoord (view, &(v->X), &(v->Y), &XR, &YR);
        DeleteStream(view, v->X, v->Y, XR, YR, FALSE);
    }

    //Set the Hour glass cursor
          hSaveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));

    //Insert first line

    res = LoadLine(line, &lineLen, d->NbLines);
    if (res == END_OF_FILE || res == END_OF_LINE) {

        //Add a CR+LF
        if (res == END_OF_LINE) {
            line[lineLen] = CR;
            line[lineLen + 1] = LF;
            lineLen += 2;
        }
        if (!InsertBlock(v->Doc, v->X, v->Y, (WORD) lineLen, line))
            goto error2;
    }
    else {

        if (res == ERR_File_Read || res == ERR_Not_A_Text_File)
              ErrorBox(res, (LPSTR)FileName);
        goto error2;
    }

    if (res != END_OF_FILE) {

        //Get current line status (we just inserted it)

        y = v->Y;
        if (!FirstLine(v->Doc, &pCurLine, &y, &pCurBlock))
              return FALSE;

        //Get next line (just after the line we just inserted)

        if (!NextLine(v->Doc, &pCurLine, &y, &pCurBlock))
              return FALSE;

        //Set offset to StoreLine start
              offset =  (LPSTR)pCurLine - (LPSTR)pCurBlock->Data;
        prevLength = pCurLine->PrevLength;

        //Split block in 2 blocks by first allocating a new block and then
        //copying right side of block in new block

        if (!AllocateBlock(pCurBlock, pCurBlock->NextBlock, &pNewBlock))
              return FALSE;

        pLastLine = (LPLINEREC)(pCurBlock->Data + pCurBlock->LastLineOffset);
        memmove(pNewBlock->Data, (LPSTR)pCurLine,
              (LPSTR)pLastLine - (LPSTR)pCurLine + pLastLine->Length);

        //Set new old block len and new new block len
              pCurBlock->LastLineOffset = (LPSTR)pCurLine - (LPSTR)pCurBlock->Data - pCurLine->PrevLength;
        pNewBlock->LastLineOffset = (LPSTR)pLastLine - (LPSTR)pCurLine;

        //Backward links next block with new one
        if (pCurBlock->NextBlock == NULL)
              d->LastBlock = pNewBlock;
        else
              (pCurBlock->NextBlock)->PrevBlock = pNewBlock;

        //Forward link current block with new block

        pCurBlock->NextBlock = pNewBlock;

        CloseLine(v->Doc, &pCurLine, y, &pCurBlock);

        //Read and store all lines in new blocks

        res = LoadLine(line, &lineLen, d->NbLines);
        while (res == END_OF_LINE) {

            //Truncate a file too large

            if (d->NbLines >= MAX_LINE_NUMBER - 1) {
                ErrorBox(ERR_Truncate_Doc);
                res = END_OF_FILE;
                break;
            }

            if (!StoreLine(line, lineLen, &offset, &prevLength, &pCurBlock)) {
                res = END_ABORT;
                break;
            }

            res = LoadLine(line, &lineLen, ++d->NbLines);
        }

        //Take decisions
        switch (res) {

          case END_OF_FILE:

            //Store last line
            if (StoreLine(line, lineLen, &offset, &prevLength, &pCurBlock)) {

                d->NbLines++;

                //Forward link of last allocated block with new block

                pCurBlock->NextBlock = pNewBlock;

                //Backward link of new block with last allocated block

                pNewBlock->PrevBlock = pCurBlock;
                ((LPLINEREC)(pNewBlock->Data))->PrevLength = (BYTE)(lineLen + LHD);

                //Free memory

                if (!DocFree(pszBufferDoc))
                      InternalErrorBox(SYS_Free_Memory);

                //Restore cursor

                SetCursor(hSaveCursor);

                //Check syntax if C

                if (d->language == C_LANGUAGE) {
                    d->lineTop = 0;
                    d->lineBottom = d->NbLines;
                    CheckSyntax(v->Doc);
                }
                SetVerticalScrollBar(view, TRUE);

                PosXY(view, v->X, v->Y, FALSE);
                InvalidateRect(v->hwndClient, (LPRECT)NULL, FALSE);

                CloseHandle (hFileDoc);
                return TRUE;
            }
            else
                goto abort;

          case ERR_File_Read:
          case ERR_Not_A_Text_File:
            ErrorBox(res, (LPSTR)FileName);
            //Fall through

          case END_ABORT:
            {

              abort:
                SetCursor(hSaveCursor);
                break;
            }

          default:
            Assert(FALSE);
            break;
        }

    } else
          InvalidateRect(v->hwndClient, (LPRECT)NULL, FALSE);

  error2: {
        SetCursor (hSaveCursor);
        if (!DocFree(pszBufferDoc))
              InternalErrorBox(SYS_Free_Memory);
    }

  error1: {
        CloseHandle (hFileDoc);
    }

    return FALSE;
}                                       /* MergeFile() */
Beispiel #6
0
/** ---------------------------------------------------------------------- **/
void PutString(int x, int y, char *Str)
{
	PosXY(x, y);
	printf("%s", Str);
}
Beispiel #7
0
/** ---------------------------------------------------------------------- **/
void GetNumeric(int x, int y, int Num)
{
	PosXY(x, y);
	scanf("%d", Num);
}
Beispiel #8
0
void Weapon::Draw(){
  if (Game::GetInstance()->ReadState() != Game::PLAYING &&
      m_last_fire_time + 100 < Time::GetInstance()->Read())
    return;

#ifndef DEBUG_HOLE
  if (m_last_fire_time + m_fire_remanence_time > Time::GetInstance()->Read())
#endif
    DrawWeaponFire();

  DrawAmmoUnits();

  ASSERT(drawable || !ShouldBeDrawn());
  if (!(drawable && ShouldBeDrawn()))
    return;

  if (ActiveCharacter().IsGhost()
      || ActiveCharacter().IsDrowned()
      || ActiveCharacter().IsDead())
    return;

  // rotate weapon if needed
  if (!EqualsZero(min_angle - max_angle)) {
    if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT)
      m_image->SetRotation_rad(ActiveCharacter().GetFiringAngle());
    else
      m_image->SetRotation_rad(ActiveCharacter().GetFiringAngle()-PI);
  } else {
    m_image->SetRotation_rad(ZERO);
  }

  // flip image if needed
  if (use_flipping) {
    m_image->SetFlipped(DIRECTION_LEFT == ActiveCharacter().GetDirection());
  }

  // Calculate position of the image
  int x,y;
  PosXY (x, y);

  // Animate the display of the weapon:
  if (m_time_anim_begin + ANIM_DISPLAY_TIME > Time::GetInstance()->Read()) {
    if (!EqualsZero(min_angle - max_angle)) {
      Double angle = m_image->GetRotation_rad();
      angle += sin(HALF_PI * Double(Time::GetInstance()->Read() - m_time_anim_begin) / ANIM_DISPLAY_TIME)
             * TWO_PI;
      m_image->SetRotation_rad(angle);
      m_image->Scale(ONE, ONE);
    }
    else {
      Double scale = sin((Double)1.5 * HALF_PI * Double(Time::GetInstance()->Read() - m_time_anim_begin) / ANIM_DISPLAY_TIME)
                   / sin((Double)1.5 * HALF_PI);
      if (scale.IsNotZero()) {
        m_image->Scale(scale, scale);
        m_image->SetFlipped(DIRECTION_LEFT == ActiveCharacter().GetDirection());
      }

      // Recompute position to get the icon centered over the skin
      if (origin == weapon_origin_OVER)
        PosXY(x,y);
    }
  } else
    m_image->Scale(ONE, ONE);

  if (m_image)
    m_image->Blit(GetMainWindow(), Point2i(x, y) - Camera::GetInstance()->GetPosition());

#ifdef DEBUG
  if (IsLOGGING("weapon")) {
    Point2i hand;
    ActiveCharacter().GetHandPosition(hand);
    Rectanglei rect(hand - 1 - Camera::GetInstance()->GetPosition(),
                    Point2i(3, 3));

    GetWorld().ToRedrawOnMap(rect);

    GetMainWindow().RectangleColor(rect, c_red);

    MSG_DEBUG("weapon.handposition", "Position: %d, %d - hand: %d, %d",
              ActiveCharacter().GetX(), ActiveCharacter().GetY(),
              hand.GetX(), hand.GetY());
  }
  if (IsLOGGING("weapon.hole")) {
    Rectanglei rect(GetGunHolePosition() - Camera::GetInstance()->GetPosition() - 1,
                    Point2i(3, 3));
  
    GetWorld().ToRedrawOnMap(rect);
    GetMainWindow().RectangleColor(rect, c_red);
  }
#endif
}