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

2014/5/6

I dont understand the image. code!

1
2
Thrillofit Thrillofit

2014/5/7

#
Oh okey! Just got it to work but seems like nothing came up in my game? http://www44.zippyshare.com/v/80924557/file.html Here is the update, Did i do something wrong?
danpost danpost

2014/5/7

#
Thrillofit wrote...
Did i do something wrong?
Well, I would not say that you did something wrong. I would say that you just did not do enough. Right now, all you can do is to test it yourself. Right click on the TestWorld class icon and select 'new TestWorld()', click on 'Run' and tap the 's' key to see how it works. The TestWorld is just a World object that I used to implement and test the Bar class in and supplied to you as an example of that. You need to be able to use a Bar object within your Space world (or in whatever class you need a bar in). The Bar class is a generic bar class, meaning it can be used for multiple purposes; not just for shield strengths. Examples: Health in hp units, Speed in any unit of distance per time; Reload timer in percent value of elapsed time to required time; any type of gauge, timer, counter, progress indicator, etc. Still, it is not as versatile as my Progress bar/health bar class, as here, zero is the only lower limit, there 'danger zone' change in color from green to red and its general appearance is not alterable. To keep things simple everything is controlled from outside the class (given its title and units of measure to use, plus its initial and maximum values when created; its value is changed from outside the class by calling the 'setValue' method on the bar object created. The value that you set it to is even stored outside the Bar class. All it does is display the value given it in bar form after given the information required.
Thrillofit Thrillofit

2014/5/7

#
danpost wrote...
Thrillofit wrote...
Did i do something wrong?
Well, I would not say that you did something wrong. I would say that you just did not do enough. Right now, all you can do is to test it yourself. Right click on the TestWorld class icon and select 'new TestWorld()', click on 'Run' and tap the 's' key to see how it works. The TestWorld is just a World object that I used to implement and test the Bar class in and supplied to you as an example of that. You need to be able to use a Bar object within your Space world (or in whatever class you need a bar in). The Bar class is a generic bar class, meaning it can be used for multiple purposes; not just for shield strengths. Examples: Health in hp units, Speed in any unit of distance per time; Reload timer in percent value of elapsed time to required time; any type of gauge, timer, counter, progress indicator, etc. Still, it is not as versatile as my Progress bar/health bar class, as here, zero is the only lower limit, there 'danger zone' change in color from green to red and its general appearance is not alterable. To keep things simple everything is controlled from outside the class (given its title and units of measure to use, plus its initial and maximum values when created; its value is changed from outside the class by calling the 'setValue' method on the bar object created. The value that you set it to is even stored outside the Bar class. All it does is display the value given it in bar form after given the information required.
Oh okey! Just got it to work now! What i did was to put the Testworld into my space world and it popped out and seems to work. The problem is now that it doesnt reload automatic. And i also think that i need to put something in my Rocket class to get the shield to work? Because by pressing S now it just make the bar more empty. or yeah. So can you like help me what the next step now is :)?
danpost danpost

2014/5/7

#
Okay. But, you may want to start from scratch by removing it back out of the Space world. Anyway, it is the Rocket class that you really need it in, unless you are planning on adding a Shield class; in that case, it would go in there.
Thrillofit Thrillofit

2014/5/7

#
Is it possible that i change some things on the first version which i had only the % counter and add ur bar but still have the shield function to work? Is it possible to do this?
danpost danpost

2014/5/7

#
I will not know exactly what to do until I know precisely what the bar will be used for. At this point, I do not even know what field value (or evaluated expression) in your project that the bar is supposed to be a display of.
Thrillofit Thrillofit

2014/5/7

#
Oh, The bar is meant to be "counter" for how much left "shieldprotecten" you have left. By that i mean that the shield function is meant that you cant get hit by a astrioed. And by a bar you will know when and how much you can use the shield protecten. Thats what i want make. And after using the full shieldprotecten bar. It should automatic reload to 100% after like 10-15 seconds and then you can use it again. By the way! i really need to apolizged my english. Im trying my best to let you know what and where i want to come:)
danpost danpost

2014/5/7

#
Not exactly. The bar is meant to be a visual display of a value that ranges from zero to some maximum number. That is it. It can be used as a timer display, a counter display, or any one of a multitude of things. This actual workings of the counter or timer or whatever is what you place inside your classes. Notice in the TestWorld class that the int field 'shieldStrength' is in the class of the world, not in the Bar class. The value of this field is controlled by the world class. Any time the value of it is changed, the world needs to tell the Bar object that displays that value to adjust to that new value. Your Rocket class has a 'shieldAmmount' field which probably should not be static and also be an int value ( 'private int shieldAmount' -- with corrected spelling ). Now, I have a suggestion about the bar. What we can do is this: add a method to the Bar class so that we can change the title so that we can alter it between 'Ready', 'Discharging' and 'Charging'; and another method to alter the color of the bar itself between green, red, and possibly one other color for the three states that the titles suggest (green when 'Ready'; orange, maybe, for 'Discharging'; and, red for 'Charging'). Now, what you will need in the Rocket class, which will be similar to what you do for the proton waves, is add the fields for the timing of the various actions (charging and discharging timer(s) ). To get an idea of exactly what we need let us briefly create a blueprint: call a method from act that runs the shield timer(s) create a method to run the shield timer(s), which will do the following
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
if shield is not active
{
    if not fully charged
    {
        add more charge
        if fully charged
        {
            set charge to maximum value
            set bar 'Ready'
        }
        adjust bar
   }
   else
   {
        if 's' key is down
        {
            activate shield;
            set bar 'Discharging'
        }
    }
}
else
{
    take some charge
    if no charge
    {
        set charge to zero
        deactivate shield
        set bar 'Charging'
    }
    adjust bar
}
Ok, from this, we can see what we will need. We need an instance boolean field to track the current state of the shield, an int field to track the amount of charge the shield has, and another int field to hold the maximum shield strength value. You already have the 'shieldAmmount' field, but let us rename it to 'shieldStrength', which more reflects what it holds. The boolean field we can name 'shieldOn' and the max int field can be named 'maxShieldStrength'. The internal value of 'maxShieldStrength can be any large positive number and the 'shieldStrength' should probably start at that same number; the change in its value can be any small portion of the maximum value and can be different amounts of changes between charging and discharging. We can add a little method called 'updateShieldBar' to adjust the display of the Bar that can be called from both places where the value of 'shieldStrength' may change from. The maximum value and the two change values can be adjusted (as int values) to accommodate any combination of charging and discharging speeds. The values do not even have to look pretty as the only value the user will see is the percentage of strength of the shields (a number between 0 and 100; which will not be unsightly). That is the basic non-technical stuff.
danpost danpost

2014/5/8

#
I realized after reading you last post that the 'blueprint' does not fit your description of what you want; but, it can be modified. Also, my suggestion about the changing caption takes away from informing what the bar is for; so, maybe just change the color of the green portion of the bar. Let me try that again:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if not active shield
{
    if charging
    {
        add some charge
        if fully charged
        {
            set strength to maximum value
            set not charging
            set bar green
        }
        adjust bar
    }
    else
    {
        if 's' down
        {
            activate shield
            set bar orange
        }
    }
}
else
{
    if not 's' down
    {
        deactivate shield
        set bar green
    }
    else
    {
        take some charge
        if charge is gone
        {
            set charge to zero
            deactivate shield
            set charging
            set bar red
        }
        adjust bar
    }
}
With this, you will need another instance boolean to track the charging state of the shield.
You need to login to post a reply.
1
2