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

2017/6/9

Bullet hell

8BITBOSSGAMES 8BITBOSSGAMES

2017/6/9

#
Im new to greenfoot and I need help. I'm making a bullet hell game and I want to create patterns but I don't know how to make a bullet clone itself. This is what I have:
1
2
3
4
5
6
7
Public class bullet extends enemy
{
    Public void act()
    {
        Int patternChoice = greenfoot.getRandomNumber(3);
        If ( patternChoice = 1) {
            for (int i = 1; i < 361; i++) {
Pattern 1 is going to be a simple spiral that turns 360 degrees. Please tell me what I do!
Super_Hippo Super_Hippo

2017/6/9

#
I am a bit confused. It is a bullet which extends enemy. For some reason you also posted this in the comment section of Fractal Fun. What exactly do you want to do? Do you want to create an image? Or do you want a bullet to move in a way to create pattern? Or do you want to spawn 360 bullets each one moving one degree differently?
danpost danpost

2017/6/10

#
I do not think that you need (or want) the bullets to clone themselves -- but rather use a different type object (a Gun class maybe) to create the bullets. It could have an int field to hold what pattern to create and maybe another int field to be used as a timer for how long to maintain the pattern. It does not need to be a visible Actor object and its rotation can be used to control the direction of each created bullet. Please respond as to whether you think that I am in the right track of what you may want.
BBurgerC7 BBurgerC7

2017/6/10

#
Well, for starters, you want the words "Public", "Int", and "If" to be all lower-case. Secondly, you must use == in if statements, a singular equal sign won't suffice. Thirdly, you must properly encase your functions. Fourthly, you might want to put something in your for loop so we have a sense of where you're going wrong. Fifthly, I would suggest that the bullet only extends from enemy if enemy is an abstract class. Sixthly, I'd recommend renaming bullet into something like enemyBullet, assuming you intend to have seperate classes for your bullet and the enemy bullet. Seventhly, 0 is the lowest value you can get from Greenfoot.getRandomNumber(3), 2 is the highest. Eightly, you want int i = 0; i < 360; i++ in order to cover every angle. I can't really help much because you only provided 7 lines of code.
BBurgerC7 BBurgerC7

2017/6/10

#
As for spiral movement(I'm assuming you just mean a circular motion), you probably just want to have it use turn() and move() every frame while using setLocation() to modify the getX() or getY() depending on the direction of the bullet. You might not even need a for loop.
You need to login to post a reply.