This site requires JavaScript, please enable it in your browser!
Greenfoot back
Xolkiyr
Xolkiyr wrote ...

2018/8/4

Using Gevater_Tod4711's Infinite Scrolling World

Xolkiyr Xolkiyr

2018/8/4

#
@Gevater_Tod4711 Not sure how to ask this, but I'm trying to use your Infinite Scrolling World code and was wondering if it was possible to track each objects World-based x and y. I couldn't understand if there was a way to do this. Basically I want to make it so that enemies outside a certain range from the starting point are supposed to get bigger and stronger. I'd also like to be able to track the player's world x and y, if that makes sense. For those not familiar with the Code I'm working with, this is a link to the basic scenario: http://www.greenfoot.org/scenarios/8270
Xolkiyr Xolkiyr

2018/8/4

#
This is my workaround that I'm trying.. not exactly accurate because I'm sure there's a much more efficient way to do it.
int newRot = (int)(getRotation()/22.5);
        if(newRot == 0){         //Right
            worldX = worldX + Speed;
        }
        if(newRot == 1){
            worldX = worldX + Speed/4;
            worldY = worldY + Speed/2;
        }
        if(newRot == 2){   //Down Right
            worldX = worldX + Speed/2;
            worldY = worldY + Speed/2;
        }
        if(newRot == 3){
            worldX = worldX + Speed/2;
            worldY = worldY + Speed/4;
        }
        if(newRot == 4){   //Down
            worldY = worldY + Speed;
        }
        if(newRot == 5){
            worldX = worldX - Speed/4;
            worldY = worldY + Speed/2;
        }
        if(newRot == 6){   //Down Left
            worldX = worldX - Speed/2;
            worldY = worldY + Speed/2;
        }
        if(newRot == 7){
            worldX = worldX - Speed/2;
            worldY = worldY + Speed/4;
        }
        if(newRot == 8){   //Left
            worldX = worldX - Speed;
        }
        if(newRot == 9){
            worldX = worldX - Speed/4;
            worldY = worldY - Speed/2;
        }
        if(newRot == 10){  //Up Left
            worldX = worldX - Speed/2;
            worldY = worldY - Speed/2;
        }
        if(newRot == 11){
            worldX = worldX - Speed/2;
            worldY = worldY - Speed/4;
        }
        if(newRot == 12){  //Up
            worldY = worldY - Speed;
        }
        if(newRot == 13){
            worldX = worldX - Speed/4;
            worldY = worldY + Speed/2;
        }
        if(newRot == 14){  //Up Right
            worldX = worldX - Speed/2;
            worldY = worldY + Speed/2;
        }
        if(newRot == 15){
            worldX = worldX - Speed/2;
            worldY = worldY + Speed/4;
        }
You need to login to post a reply.