Code definition help

This is a discussion on Code definition help within the C Programming forums, part of the General Programming Boards category; Hi all I was given a piece of code for my assignment, i understand most of it, apart from this ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    12

    Code definition help

    Hi all

    I was given a piece of code for my assignment, i understand most of it, apart from this section, could someone please explain it too me?

    Its a pacman style game, with the coloured fish being the enemies.

    I can post more code if needed

    Code:
    if ((REDFISH.GetPositionX() < (PLAYER.GetPositionX() + 10)) && (REDFISH.GetPositionX() > PLAYER.GetPositionX()) && (REDFISH.GetPositionY() < (PLAYER.GetPositionY() + 0.2)) && (REDFISH.GetPositionY() > (PLAYER.GetPositionY() - 0.2))) {
    		redfishmove = 0;
    	}
    
    	if ((REDFISH.GetPositionX() > (PLAYER.GetPositionX() - 10)) && (REDFISH.GetPositionX() < PLAYER.GetPositionX()) && (REDFISH.GetPositionY() < (PLAYER.GetPositionY() + 0.2)) && (REDFISH.GetPositionY() > (PLAYER.GetPositionY() - 0.2))) {
    		redfishmove = 1;
    	}
    
    	if ((REDFISH.GetPositionY() > (PLAYER.GetPositionY() - 10)) && (REDFISH.GetPositionY() < PLAYER.GetPositionY()) && (REDFISH.GetPositionX() < (PLAYER.GetPositionX() + 0.2)) && (REDFISH.GetPositionX() > (PLAYER.GetPositionX() - 0.2))) {
    		redfishmove = 2;
    	}
    
    	if ((REDFISH.GetPositionY() < (PLAYER.GetPositionY() + 10)) && (REDFISH.GetPositionY() > PLAYER.GetPositionY()) && (REDFISH.GetPositionX() < (PLAYER.GetPositionX() + 0.2)) && (REDFISH.GetPositionX() > (PLAYER.GetPositionX() - 0.2))) {
    		redfishmove = 3;
    	}

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Just logic to determine if redfish should get a move value of 0, 1, 2, or 3.

    The lines of code are long, but the logic of what they're doing, is not complex. Don't let the looks of it intimidate you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  2. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21