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

2018/12/26

Game Creation: Directional Idle, Shooting and Jumping.

5
6
7
8
9
10
Unlimited Unlimited

2018/12/29

#
Have i said something wrong?
danpost danpost

2018/12/29

#
Unlimited wrote...
Have i said something wrong?
Not at all. I've just been out. Also, I do not know what you have, as far as these animations are concerned. I have noticed some out of memory errors with the current code, however. You may be stretching the limits with all the animations.
Unlimited Unlimited

2018/12/30

#
Yes there is indeed sometimes a error that says java is out of heap space however this is fixed most of the times by just closing and reopening the programm. I have a lot of animations and while you were gone ive managed to implement them all. Ive probably done it in a way you would not have but it seems to be working. Ive added the dashing animations in both directions and shooting. I am currently building the level itself and next i would try to implement the shooting animation actually shooting something and enemies. if you would like to see my code i can post it here, however i have to say i reused some of my old method for the jumps and ground to fuctions as the previous method just didnt work or at least i would not know how to fix it. I tried my hardest so keypresses are only registered once like youve suggested.
Unlimited Unlimited

2018/12/30

#
Ah yes concerning the level, is there a problem if i load in the entire level at once with the addObject method in example world or is that fine? If its not fine is there a better way to do it?
danpost danpost

2018/12/30

#
Unlimited wrote...
is there a problem if i load in the entire level at once with the addObject method in example world or is that fine?
I would not anticipate any prroblems.
Unlimited Unlimited

2018/12/30

#
Ah alright, that is good to know.
Unlimited Unlimited

2018/12/30

#
Is there a good way to create events for enemies so they only start to move once you are like 2 screen sizes away from them? I dont have any enemy class yet i was just currious.
danpost danpost

2018/12/30

#
Unlimited wrote...
Is there a good way to create events for enemies so they only start to move once you are like 2 screen sizes away from them? I dont have any enemy class yet i was just currious.
If you are asking if there is a way to trigger an enemy to do something when within a certain range of the player, you can use the getObjectsInRange method for checking proximity.
Unlimited Unlimited

2018/12/30

#
Ah okay thanks.
Unlimited Unlimited

2018/12/30

#
Is it possible to remove the character or rather replace it with a animation like explosion if the world edge is touched? I know its possible on a regular world but i dont know how to do it on a scrolling world. Do you maybe have an Idea?
danpost danpost

2018/12/30

#
Unlimited wrote...
Is it possible to remove the character or rather replace it with a animation like explosion if the world edge is touched? I know its possible on a regular world but i dont know how to do it on a scrolling world. Do you maybe have an Idea?
Should be no different
Unlimited Unlimited

2019/1/1

#
So, next i wanted to make a enemy that walks back and fourth on a plattform and randomly (or after two (repetetions or something liek that) turns to the player and begins to shoot (as in it stops for a couple of seconds and then resumes to walk) The code i have looks liek this.
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
public class Vile extends Enemy
{
    private int vSpeed = 0;
    private int acceleration = 1;
    private int shootingCounter = 10;
    private int spriteHeight = getImage().getHeight();
    private int spriteWidth = getImage().getWidth();
    private int lookForGroundDistance = (int)spriteHeight/2;
    private int lookForEdge = (int)spriteWidth/2;
    private int speed = 15;
     
    private int animCount; // counter for animations
    private int animDelay = 6; // initially set for standing animation (frame rate field)
     
    private static GreenfootImage[] VileStandAnim = new GreenfootImage[1];
    private static GreenfootImage[] VileStandLeftAnim = new GreenfootImage[1];
    private static GreenfootImage[] rightAnim = new GreenfootImage[2];
    private static GreenfootImage[] leftAnim = new GreenfootImage[2];
    private static GreenfootImage[] shootAnim = new GreenfootImage[1];
    private static GreenfootImage[] shootLeftAnim = new GreenfootImage[1];
     
     
    static
    {
        for (int i=0; i<VileStandAnim.length; i++) VileStandAnim[i] = new GreenfootImage("VileStand_0"+(i+1)+".png");
        for (int i=0; i<VileStandLeftAnim.length; i++) VileStandLeftAnim[i] = new GreenfootImage("VileStandLeft_0"+(i+1)+".png");
        for (int i=0; i<rightAnim.length; i++) rightAnim[i] = new GreenfootImage("VileDash_0"+(i+1)+".png");
        for (int i=0; i<leftAnim.length; i++) leftAnim[i] = new GreenfootImage("VileDashLeft_0"+(i+1)+".png");
        for (int i=0; i<shootAnim.length; i++) shootAnim[i] = new GreenfootImage("VileShoot_0"+(i+1)+".png");
        for (int i=0; i<shootLeftAnim.length; i++) shootLeftAnim[i] = new GreenfootImage("VileShootLeft_0"+(i+1)+".png");
    }  
     
    private void setAnim(GreenfootImage[] anim, int frameRate)
    {
        animSet = anim;
        animCount = -1; // prepares to set first image when incremented
        animDelay = frameRate;
        animate(); // calls a method to set a frame of this newly set animation
    }
     
     
     
    private GreenfootImage[] animSet = VileStandLeftAnim;
     
     
    /**
     * Act - do whatever the Vile wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        animate();
        checkAnim();
         
        move();
    }
     
    public void move()
    {
        Actor ground = getOneObjectAtOffset(lookForEdge, lookForGroundDistance, Collider.class);
         
        if(ground == null)
        {
            speed *= -1;
            lookForEdge *= -1;
        }
        else
        {
            move(speed);
             
        }
    }
     
    public void checkAnim()
    {
        if(speed == 15 && animSet != rightAnim )setAnim(rightAnim, 2);
        else if(speed == -15 && animSet != leftAnim) setAnim(leftAnim, 2);
         
    }
Unlimited Unlimited

2019/1/1

#
Also could you clearify on how i would add the method for the enemy to only react at a certain distance?
danpost danpost

2019/1/1

#
Unlimited wrote...
i wanted to make a enemy that walks back and fourth on a plattform and randomly (or after two (repetetions or something liek that) turns to the player and begins to shoot (as in it stops for a couple of seconds and then resumes to walk) The code i have looks liek this. << Code Omitted >>
Where are you even checking for a platforrm or even an Azure object?
danpost danpost

2019/1/1

#
Unlimited wrote...
you clearify on how i would add the method for the enemy to only react at a certain distance?
A method does not restrict actions -- only a conditional can do that (an if statement). What do you think it would look like?
There are more replies on the next page.
5
6
7
8
9
10