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

2015/1/1

How to make the background "wrap" and repeat in Space Shooter Game by Azhar Chaudhry?

Kendall Kendall

2015/1/1

#
My class has been working on the space shooter game by Azhar Chaudhry. He walks us through most of the coding, but leaves some of it up to us at the end and gives us a hint. I am on the second part: Background, we are supposed to code to make the background look as if it is continuously scrolling. We are supposed to a) In the City class add another background to begin a short distance after the first background ends b) In the Background class create a new method called 'repeater' to move the background to a new X location if the background has gone off-screen fully. The repeater method should have a reference inside the Act method. I do not understand this at all. This is my first year of coding in school, and I am so confused. Can anyone help explain what I should use to accomplish this? Here is the link to the tutorial website: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAA&url=http%3A%2F%2Fwww.stedgymdenbosch.nl%2Fsubsites%2Finformatica%2Fdata%2FG6%2FGreenfoot_shooter_tutorial%2Findex.html&ei=-d2lVOrcIcyxggT-oILQBA&usg=AFQjCNFn-whpdd6QhK_27Xb885eoSGFp-w&sig2=znvZSMqiqUGD7D5GWROpuA
danpost danpost

2015/1/2

#
When the right edge of one background object scrolls into view, you will need the other one to continue the image of the background. Its location in the world should always be exactly one image width distance from the other background object. Also, once one is totally off the screen to the left, it should be moved around to the other side of the other background object. This 'leap frog' action performs the repeating of the wrapping. Azhar justs wants you to create a new method called 'repeater' (private void) to check the x location and move the actor back off the right side if it is found off the left side; and this new method is to be called from the 'act' method.
shabs shabs

2015/4/8

#
Hi @danpost, do you know how to do the code for this... i am doing the same project in i.c.t and i have no idea on what it means. If you know the code or know a video which can explain it, i would be very grateful
danpost danpost

2015/4/8

#
@shabs, what part are you having problems with? adding the Background object? getting it to move? getting it to move to the end? or relocating it from off the left edge to off the right edge?
shabs shabs

2015/4/8

#
@danpost.... i don't understand most of it. This is my first year of coding. But the main bits are a) In the City class add another background to begin a short distance after the first background ends b) In the Background class create a new method called 'repeater' to move the background to a new X location if the background has gone off-screen fully. The repeater method should have a reference inside the Act method. I would be really happy if you can help
shabs shabs

2015/4/8

#
@danpost if you need a link to the website it is: www.year9computing.esy.es/Shoot Greenfoot tutorial/2-background.html
danpost danpost

2015/4/8

#
I briefly went over a couple of the videos in the area you are working on. I believe what they want is for you to include two Background objects in your world that will 'leap-frog' over one another. That is, after one entirely goes out of view, it is moved passed the other object which is now currently visible on the screen. So, you would create and add two Background objects into your world placed, preferably, one image width apart from each other. Then in the Background class, you would give the objects the behavior wanted by adding a method to keep tabs on its location. If its location is half an image width off the left edge, then move it two image widths ahead of where it currently is (one would place it exactly over the other object; two moves it to the other side of the other object). Call this method from the act method in the Background class (that is what was meant by 'have a reference inside the Act method').
shabs shabs

2015/4/8

#
@danpost thanks, that makes a lot more sense.. Thanks for all the help
TheSalmon TheSalmon

2015/4/9

#
@shabs what was the code you put in, i'm stuck and i need to finish the project soon
mendg025 mendg025

2015/4/10

#
yea me too @shabs
You need to login to post a reply.