Example #1
0
void passBall()
{
	int flag1=0;
	int flag2=0;
	TC_Position target;
	if(iHero_1.b_ghostball==true)
	{
       flag1=PassBallState(hHero_1);
	   if(flag1==-1)
		  Goal();
	   else
	   {
        target=GetPassBallPositon(hHero_1);
		 if(target.x==-1||target.y==-1)
			 Goal();
		 else
		    Tc_PassBall(hHero_1,target);	  
	   }
	}
	if(iHero_2.b_ghostball==true)
	{
      flag2=PassBallState(hHero_2);
	   if(flag2==-1)
		  Goal();
	   else
	   {
         target=GetPassBallPositon(hHero_2);
		  if(target.x==-1||target.y==-1)
			  Goal();
		  else
	        Tc_PassBall(hHero_2,target);
	   }
	}
}
void PartialOrderPlanner::addOpenGoals(PartialOrderPlan& plan, const Operator& newOperator)
{
    for (auto itr = newOperator.preconditions.begin() ;itr != newOperator.preconditions.end();++itr)
    {
        plan.open.push(Goal(newOperator.id, *itr));
    }
}
      float botdpointx(float &dpointy,float &slope)
    {
      int x;
      float dpointx,flag=0;

      if(state->ballVel.abs() < 200 && abs(state->ballVel.y) > 0)
      {
        if(ForwardX(state->ballPos.x) > 0 && ForwardX(state->ballPos.x) < HALF_FIELD_MAXX)
        dpointx = state->ballPos.x - 4*ForwardX(BOT_RADIUS);
        else dpointx = 0;
          
        slope=atan2((state->ballPos.y - state->homePos[botID].y),(state->ballPos.x - state->homePos[botID].x));
        
      }
      else
      {
        x =  (state->ballVel.x/ state->ballVel.y)*(dpointy - state->ballPos.y) + state->ballPos.x;
        dpointx = ForwardX(HALF_FIELD_MAXX)/2,flag=0;
				Vector2D<int>Goal(OPP_GOAL_X,0);
				slope = Vector2D<int>::angle(Goal,state->homePos[botID]);
        if(state->ballVel.y  * state->homePos[botID].y > 0)
        {
          //printf("In\n");
          if(ForwardX(x) < (3*HALF_FIELD_MAXX)/2)
            dpointx = ForwardX(2*HALF_FIELD_MAXX - BOT_RADIUS) - x, slope=atan(state->ballVel.y/state->ballVel.x),flag=1;
          if(ForwardX(x) < HALF_FIELD_MAXX)
          {
            dpointx = ForwardX(HALF_FIELD_MAXX-GOAL_DEPTH-DBOX_WIDTH);
						if(ForwardX(x) >= ForwardX(HALF_FIELD_MAXX)/2)
							dpointy = SGN(state->ballVel.y)*OUR_GOAL_MAXY;
						if(ForwardX(state->ballVel.x)>0)
							slope=atan(-state->ballVel.x/state->ballVel.y),flag=2;
          }
          if(ForwardX(x) < HALF_FIELD_MAXX/2)
          {
						dpointx = x - 4*ForwardX(BOT_RADIUS);
						if(ForwardX(state->ballVel.x)>0)
							slope=atan(-state->ballVel.x/state->ballVel.y),flag=2;
          }
          if(ForwardX(x) < 0)
            dpointx = 0 , slope=atan2((state->ballPos.y - state->homePos[botID].y),(state->ballPos.x - state->homePos[botID].x)),flag=3;
        }
        
//        if(flag==0)
//          printf("Center\n");
//          else if(flag==1)
//            printf("Reflection\n");
//            else if(flag==2)
//              printf("Predict No Reflection\n");
//              else if(flag==3)
//                printf("Near our goal\n");
      }
      if(dpointx >3 * ForwardX(HALF_FIELD_MAXX)/4 && dpointx < ForwardX(HALF_FIELD_MAXX))
        dpointx = 3 * ForwardX(HALF_FIELD_MAXX)/4;
        
        //*slope = atan2((state->ballPos.y - state->homePos[botID].y),(state->ballPos.x - state->homePos[botID].x));
        
       return dpointx;
    }
void makeNanobotPath(NanobotDetails& Nanobot,
                     OctreePtr TheOctree,
                     WindowEventProducer* TheWindow,
                     const Pnt3f& Min,
                     const Pnt3f& Max)
{
    //Get the nanobots current location
    Pnt3f NonobotLoc(Nanobot._Transform->getMatrix() * Pnt3f(0.0f,0.0f,0.0f));

    std::vector<Pnt3f> NanobotPath;
    do
    {
        //Randomly find a destination location
        Pnt3f Goal(randomOpenPosition(Min,Max,TheOctree));

        //Try and find a path to that location
        OctreeAStarAlgorithm AlgorithmObj;
        SLOG << "Started AStar Search" << std::endl;
        Time StartTime = getSystemTime();
        NanobotPath = AlgorithmObj.search(TheOctree,NonobotLoc,Goal);
        SLOG << "Finished AStar Search: " << getSystemTime() - StartTime << " s" << std::endl;
        if(NanobotPath.size() > 2)
        {
            NanobotPath.front() = NonobotLoc;
            NanobotPath.back() = Goal;
            NanobotPath = smooth(NanobotPath,4);

            //Make an animation for the nanobot to that location
            if(Nanobot._Animation != NULL)
            {
                Nanobot._Animation->stop();
                Nanobot._Animation->detachUpdateProducer();
            }
            Nanobot._Animation = setupAnimation(NanobotPath, Nanobot._Transform);
            Nanobot._Animation->attachUpdateProducer(TheWindow);
            Nanobot._Animation->start();

            Nanobot._PathVisNode->setCore(createPathGeometry(NanobotPath));
        }
    }while(NanobotPath.size() <= 2);
}
    void execute(const Param& tParam)
    {

      switch(iState)
      {
                                
        case POSITIONING:
        {
					//printf("POSITIONING\n");
					sID = SkillSet::GoToPoint;
					sParam.GoToPointP.y = -SGN(state->ballPos.y)*(HALF_FIELD_MAXY-2*BOT_RADIUS)/2;          
					sParam.GoToPointP.x = botdpointx(sParam.GoToPointP.y,sParam.GoToPointP.finalslope);
					SkillSet::addCircle(sParam.GoToPointP.x,sParam.GoToPointP.y,50, 0xFFF000);
					sParam.GoToPointP.align = false;
					char debug[100];
					sprintf(debug,"our ball %d\n",state->pr_ourBall);
					//Client::debugClient->SendMessages(debug);
					if(ball_coming())
						iState = CHARGE;
					if((/*ball_coming() || ((!state->pr_ourBall || botID==state->ourBotNearestToBall) && */(state->ballPos.y * state->homePos[botID].y > 0) && (ForwardX(state->ballPos.x) > ForwardX(state->homePos[botID].x) && (fabs(state->ballPos.y) < fabs(state->homePos[botID].y)) && ForwardX(state->ballVel.x)<0 )) || (/*(!state->pr_ourBall || botID==state->ourBotNearestToBall)&&*/Vector2D<int>::dist(state->ballPos,state->homePos[botID]) < 4*BOT_RADIUS))
					{
						iState = APPROACH;
					}
					break;
        }
        
        case APPROACH:
        {
          //printf("APPROACH\n");
          sID = SkillSet::GoToPoint;
          sParam.GoToPointP.y = state->ballPos.y;          
          sParam.GoToPointP.x = state->ballPos.x;					
					Vector2D<int>Goal(OPP_GOAL_X,0);
					sParam.GoToPointP.finalslope = Vector2D<int>::angle(Goal,state->ballPos);
          sParam.GoToPointP.align = true;
					SkillSet::addCircle(sParam.GoToPointP.x,sParam.GoToPointP.y,50, 0xFFF000);
					//ballcoming = ball in cone formed by bot and goal max/min points
          if(!((/*ball_coming() || ((!state->pr_ourBall || botID==state->ourBotNearestToBall) &&*/ (state->ballPos.y * state->homePos[botID].y > 0) && (ForwardX(state->ballPos.x) > ForwardX(state->homePos[botID].x)) && (fabs(state->ballPos.y) < fabs(state->homePos[botID].y)) && ForwardX(state->ballVel.x)<0 ) || (/*(!state->pr_ourBall || botID==state->ourBotNearestToBall) && */Vector2D<int>::dist(state->ballPos,state->homePos[botID]) < 4*BOT_RADIUS)))
          {
            iState = POSITIONING;
          }
          else if(Vector2D<int>::dist(state->ballPos,state->homePos[botID]) < BOT_BALL_THRESH && ForwardX(state->ballPos.x > 0))
          {
            iState = REATTACK;
          }
          break;
        }
        
        case REATTACK:
        {
          //printf("REATTACK\n");
          sID = SkillSet::GoToPoint;
          sParam.GoToPointP.align = false;
          sParam.GoToPointP.x = OPP_GOAL_X;
          sParam.GoToPointP.y = 0;
          sParam.GoToPointP.finalslope = Vector2D<int>::angle(Vector2D<int>(OPP_GOAL_X, 0), state->ballPos);
          sParam.GoToPointP.increaseSpeed = 1;
          SkillSet::addCircle(sParam.GoToPointP.x,sParam.GoToPointP.y,50, 0xFFF000);
          if(Vector2D<int>::dist(state->ballPos,state->homePos[botID]) > BOT_BALL_THRESH)
          {
            iState = POSITIONING;
          }
          break;
        }

				case CHARGE:
				{
					sID = SkillSet::ChargeBall;
					if(!ball_coming())
						iState = POSITIONING;
					break;
				}
      }
        
      skillSet->executeSkill(sID,sParam);
    }
Example #6
0
void catchGoldBall()//还是按方位来判断
{
	 if(iGoldBall.b_visible==true)
	 {    
		 int disSmall=64;
		 int left,right,up,down;
		 up=0;
		 down=TC_MAP_HEIGHT-(int)0.5*TC_GOLDBALL_WIDTH;
		 if(iAttackDirection==TC_DIRECTION_RIGHT)
		 {
			 left=iOwnGate.x;
			 right=iEnemyGate.x-128;
		 }
		 else
		 { 
			 left=iEnemyGate.x;
			 right=iOwnGate.x-128;
		 }
		 int disL=abs(int(iGoldBall.pos.x-left));
		 int disR=abs(int(right-iGoldBall.pos.x));
		 int disU=abs(int(iGoldBall.pos.y-up));
		 int disD=abs(int(down-iGoldBall.pos.y));
        TC_Position pos2;
		if(disL<=disSmall&&disU<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
			  pos2.x=right-disL;
			  pos2.y=down-disU;
			  goldBall.x=iGoldBall.pos.x;
			  goldBall.y=iGoldBall.pos.y;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
			   goldBall.x=iGoldBall.pos.x;
			   goldBall.y=iGoldBall.pos.y;
			}
		}
		else if(disR<=disSmall&&disD<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
			  pos2.x=left+disR;
			  pos2.y=up+disD;
			  goldBall.x=iGoldBall.pos.x;
			  goldBall.y=iGoldBall.pos.y;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
				goldBall.x=iGoldBall.pos.x;
			   goldBall.y=iGoldBall.pos.y;
			}
		}
		else if(disL<=disSmall&&disD<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
				pos2.x=right-disL;
			   pos2.y=up+disD;
			   goldBall.x=iGoldBall.pos.x;
			   goldBall.y=iGoldBall.pos.y;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
							  goldBall.x=iGoldBall.pos.x;
			  goldBall.y=iGoldBall.pos.y;
			}
		}
		else if(disR<=disSmall&&disU<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
				pos2.x=left+disR;
		       pos2.y=down-disU;
			   goldBall.x=iGoldBall.pos.x;
			   goldBall.y=iGoldBall.pos.y;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
							  goldBall.x=iGoldBall.pos.x;
			  goldBall.y=iGoldBall.pos.y;
			}
		}  
		else if(disL<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
			pos2.x=right-disL;
			pos2.y=iGoldBall.pos.y;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
			}

		}
		else if(disR<=disSmall)
		{
		  if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
		  {
			  pos2.x=left+disR;
			  pos2.y=iGoldBall.pos.y;
		  }
		  else
		  {
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
		  }
		}
		else if(disU<=disSmall)
		{
			if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
			{
			pos2.y=down-disU;
			pos2.x=iGoldBall.pos.x;
			}
			else
			{
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
			}
		}
		else if(disD<=disSmall)
		{
         if(goldBall.x==-1||goldBall.y==-1||getDisdance(goldBall,iGoldBall.pos)<100)
		 { 
			pos2.y=up+disD;
			pos2.x=iGoldBall.pos.x;
		 }
		 else
		 {
				pos2.x=goldBall.x;
				pos2.y=goldBall.y;
		 }
		}
		else
		{
			pos2.y=up+disD;
			pos2.x=iGoldBall.pos.x;
		}
		 if(abs((int)gameInfo.score_enemy-(int)gameInfo.score_self)<=2)//是否做出修改
              Goal();
		 else if(gameInfo.score_enemy>gameInfo.score_self)//抢球
		 {
	       	 double d1=getDisdance(iHero_1.pos,iGoldBall.pos);
			 double d2=getDisdance(iHero_2.pos,iGoldBall.pos);
			 if(d1<d2)
			 {
			   int direction1=GetMoveDirection(iHero_1.pos,iGoldBall.pos);
			     direction1=getOutOfTrap(iHero_1.pos,direction1);
			   if(direction1!=-1)
               Tc_Move(hHero_1,DirHash[direction1]);
              
			   int direction2=GetMoveDirection(iHero_2.pos,pos2);
			   direction2=getOutOfTrap(iHero_2.pos,direction2);
			  Tc_Move(hHero_2,DirHash[direction2]);
			 }
			 else
			 {
			   int direction1=GetMoveDirection(iHero_2.pos,iGoldBall.pos);
			     direction1=getOutOfTrap(iHero_2.pos,direction1);
			   if(direction1!=-1)
               Tc_Move(hHero_2,DirHash[direction1]);
              
			   int direction2=GetMoveDirection(iHero_1.pos,pos2);
			   direction2=getOutOfTrap(iHero_1.pos,direction2);
			  Tc_Move(hHero_1,DirHash[direction2]);
			 }
		 }
		 else 
		 {
             int direction1=GetMoveDirection(iHero_1.pos,iEnemy_1.pos);
			     direction1=getOutOfTrap(iHero_1.pos,direction1);
			   if(direction1!=-1)
               Tc_Move(hHero_1,DirHash[direction1]);
              
			   int direction2=GetMoveDirection(iHero_2.pos,iEnemy_2.pos);
			   direction2=getOutOfTrap(iHero_2.pos,direction2);
			  Tc_Move(hHero_2,DirHash[direction2]);
		 }
		  if(iHero_1.b_snatch_goldball==true)
           Tc_SnatchBall(hHero_1,TC_GOLD_BALL);
	      if(iHero_2.b_snatch_goldball==true)    
	        Tc_SnatchBall(hHero_2,TC_GOLD_BALL);
	 }
}
// Initialize GLUT & OpenSG and set up the rootNode
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectKeyPressed(boost::bind(keyPressed,_1));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        UInt32 SceneMask(1),
               PathMask(4);

        BoostPath SceneFilePath(".//Data//CellParts.osb");

        if(argc >= 2)
        {
            SceneFilePath = BoostPath(argv[1]);
            if(!boost::filesystem::exists(SceneFilePath))
            {
                SceneFilePath = BoostPath(".//Data//CellParts.osb");
            }
        }

        //Make Base Geometry Node
        NodeRecPtr SceneGeometryNode =
            SceneFileHandler::the()->read(SceneFilePath.string().c_str());
        SceneGeometryNode->setTravMask(SceneMask);
        if(SceneGeometryNode == NULL)
        {
            SceneGeometryNode = makeTorus(1.0, 10.0, 24, 24);
        }

        //Construct the Root Node
        NodeRecPtr RootNode = makeCoredNode<Group>();
        RootNode->addChild(SceneGeometryNode);
        commitChanges();

        //Create the Octree

        SLOG << "Started Building Octree" << std::endl;
        SLOG << "This may take some time ..." << std::endl;
        Time StartTime;
        StartTime = getSystemTime();
		OctreePtr TheOctree =
            Octree::buildTree(RootNode,SceneMask,6,1.5,true);

        SLOG << "Building Octree: " << getSystemTime() - StartTime << " s" << std::endl;
        Pnt3f Min,Max;
        TheOctree->getRoot()->getVolume();
        SLOG << "Octree: "<< std::endl
             << "    Depth: " << TheOctree->getDepth() << std::endl
             << "    Bounds: " << TheOctree->getRoot()->getVolume().getMin() << "  :  " << TheOctree->getRoot()->getVolume().getMax() << std::endl
             << "    NodeCount: " << TheOctree->getNodeCount() << std::endl
             << "    LeafNodeCount: " << TheOctree->getLeafNodeCount() << std::endl
             << "    BranchNodeCount: " << TheOctree->getBranchNodeCount() << std::endl
             << "    IntersectingNodeCount: " << TheOctree->getIntersectingNodeCount() << std::endl
             << "    IntersectingLeafNodeCount: " << TheOctree->getIntersectingLeafNodeCount() << std::endl;

        //Create the Path Geometry
        //Generate the Path
        OctreeAStarAlgorithm AlgorithmObj;
        SLOG << "Started AStar Search" << std::endl;
        StartTime = getSystemTime();
        Pnt3f Start(-4.01f,1.01f,10.01f),Goal(-4.01f,-0.01f,-7.01f);
        std::vector<Pnt3f> Path =
            AlgorithmObj.search(TheOctree,Start,Goal);
        Path.front() = Start;
        Path.back() = Goal;
        SLOG << "Finished AStar Search: " << getSystemTime() - StartTime << " s" << std::endl;

        NodeRecPtr PathNode = createPathGeometry(Path);
        PathNode->setTravMask(PathMask);
        RootNode->addChild(PathNode);

        NodeRecPtr StartNode = makeSphere(1.0, 2);
        TransformRecPtr StartNodeTransform = Transform::create();
        Matrix StartNodeMatrix;
        StartNodeMatrix.setTranslate(Start);
        StartNodeMatrix.setScale(0.1f);
        StartNodeTransform->setMatrix(StartNodeMatrix);
        NodeRecPtr StartNodeTransformNode = makeNodeFor(StartNodeTransform);
        StartNodeTransformNode->addChild(StartNode);
        StartNodeTransformNode->setTravMask(PathMask);
        RootNode->addChild(StartNodeTransformNode);

        NodeRecPtr GoalNode = makeSphere(1.0, 2);
        TransformRecPtr GoalNodeTransform = Transform::create();
        Matrix GoalNodeMatrix;
        GoalNodeMatrix.setScale(0.1f);
        GoalNodeMatrix.setTranslate(Goal);
        GoalNodeTransform->setMatrix(GoalNodeMatrix);
        NodeRecPtr GoalNodeTransformNode = makeNodeFor(GoalNodeTransform);
        GoalNodeTransformNode->addChild(GoalNode);
        GoalNodeTransformNode->setTravMask(PathMask);
        RootNode->addChild(GoalNodeTransformNode);


        //Set the background
        SolidBackgroundRecPtr TheBackground = SolidBackground::create();
        TheBackground->setColor(Color3f(0.0f,0.0f,0.0f));

        // tell the manager what to manage
        sceneManager.setRoot  (RootNode);
        sceneManager.getWindow()->getPort(0)->setBackground(TheBackground);

        // show the whole RootNode
        sceneManager.showAll();

        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "01AStarPathing");

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
Example #8
0
void Editor::check(double mousex, double mousey, int pixelx, int pixely, bool click, bool onSpace, bool leftButton)
{
  unsigned int i;
  bool canRemove = false;
  bool wasRemoving = false; 

  if(setGalaxy || setHole)
  {
    if(click)
    {
      if(setHole)
      {
        uni.holes.back().vx = -(uni.holes.back().x-mousex)*2e6;
        uni.holes.back().vy = -(uni.holes.back().y-mousey)*2e6;
      }
      else
      {
        uni.galaxies.back().vx = -(uni.galaxies.back().x-mousex)*2e6;
        uni.galaxies.back().vy = -(uni.galaxies.back().y-mousey)*2e6;
      }
      uni.calcStars();
      setGalaxy = false;
      setHole = false;
      canPut = true;
    }
  } 
  else 
  {
    if(!onSpace)
    {
      canPut = false;
    }
    else
    {
      canPut = true;
      for(i = 0; i < uni.holes.size(); i++)
      {
	if( MPYTH(uni.holes[i].x, uni.holes[i].y, uni.holes[i].radius) )
	{
	  canPut = false;

	  /* pruefen ob der ueberhaupt geloescht werden darf */
	  if(!uni.holes[i].inLevel() || all)
	  {
	    canRemove = true;

	    if(click)
	    {
	      if(!all)
	      {
	        massreserve += uni.holes[i].mass;
	      }
	      uni.holes.erase(uni.holes.begin()+i);
	      wasRemoving = true;
	    }
	  }
	}
      }

      if(!wasRemoving)
      {
	for(i = 0; i < uni.galaxies.size(); i++)
	{
	  if( MPYTH(uni.galaxies[i].x, uni.galaxies[i].y, uni.galaxies[i].radius*4) )
	  {
	    canPut = false;

	    if(all)
	    {
	      canRemove = true;
	      if(click)
	      {
		uni.galaxies.erase(uni.galaxies.begin()+i);
		uni.calcStars();
		wasRemoving = true;
	      }
	    }
	  }
	}
      }

      if(!wasRemoving)
      {
	if( MPYTH(uni.goal.x, uni.goal.y, uni.goal.radius) )
	{
	  canPut = false;

	  if(all)
	  {
	    canRemove = true;
	    if(click)
	    {
	      uni.goal = Goal();
	      wasRemoving = true;
	    }
	  }
	}
      }
    
      if(canRemove && !wasRemoving)
      {
        SDL_SetCursor(scissors);
      } else {
	SDL_SetCursor(pointer);
      }

      if(canPut)
      {
	if(click)
	{
	  if(!all)
	  {
	    if(massreserve >= getHoleWeight())
	    {
	      massreserve -= getHoleWeight();
	      uni.holes.push_back(Blackhole(mousex,mousey,getHoleWeight()));        
	      canPut = false;
	      canRemove = true;
              SDL_SetCursor(scissors);
	    }
	  }
	  else
	  {
	    switch(type)
	    {
	      case hole:
		setHole = true;
		canPut = false;
		galaxyX = pixelx;
		galaxyY = pixely;
		uni.holes.push_back(Blackhole(mousex,mousey,getHoleWeight()));
		break;
	      case bulge:
		setGalaxy = true;
		canPut = false;
		galaxyX = pixelx;
		galaxyY = pixely;
		srand(time(NULL));
		uni.galaxies.push_back(Galaxy(mousex,mousey,getBulgeWeight(),!leftButton,(rand()%2)));
		uni.calcStars();
		break;
	      case goal:
		uni.goal.x = mousex;
		uni.goal.y = mousey;
		uni.goal.radius = getGoalRadius();
		SDL_SetCursor(scissors);
		break;
	      default:
		// nix setzen
		break;
	    }
	  }
	}
      }
    }
  }
}