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

Report as inappropriate.

GUARDIAN-X
GUARDIAN-X presents ...

2014/9/23

Belt of Danger

This version is a recent update to the previous which lacked some needed features. One of which is the added alien ships. Also some bug fixes. Shooting alien ships will be in the next update.
It is a Scenario modeled after the Scenario "Space Bound".
It will be updated and new features are sure to be added.

Please feel free to use my source codes in your own game!

Please comment!

1555 views / 8 in the last 7 days

Tags: space game simulation shooter with-source retro 8-bit side-scroll

open in greenfoot
Your browser does not support the canvas tag.
danpostdanpost

2014/10/10

You can pass it using 'new Gameover(int)' (you will need to adjust your constructor declaration statement to accept the int value) or you can 'pass' it after creating the Gameover world: [code]Gameover go = new Gameover(); go.getBackground().drawImage(new GreenfootImage("Final score: "+score, 36, null, null)); Greenfoot.setWorld(go);[/code]
danpostdanpost

2014/10/10

I forgot to add the location coordinates to draw the image in the 'drawImage' line; also, the colors ('null' values in the example) can be replaced with actual colors. The example was just one possible way of adding the final score into the Gameover world.
GUARDIAN-XGUARDIAN-X

2014/10/10

Thanks for the help! I will implement this in my next update!
GUARDIAN-XGUARDIAN-X

2014/10/24

Your browser is ignoring the <APPLET> tag. What does this mean and how do I fix? Someone kindly explain. Thanks!
GUARDIAN-XGUARDIAN-X

2014/10/24

Danpost I am still having issues with the code you gave me. To give you a little more input on the way the score counter code looks, its like this, only its on a different world. But im trying to pass the same code to the Gameover world. here is the score counter code on the main Space world: [code]private void addAsteroids(int count) { for(int i = 0; i < count; i++) { int x = Greenfoot.getRandomNumber(getWidth()/2); int y = Greenfoot.getRandomNumber(getHeight()/2); addObject(new Asteroid(), x, y); } } private void addUFOs(int count) { for(int i = 0; i < count; i++) { int x = Greenfoot.getRandomNumber(getWidth()/2); int y = Greenfoot.getRandomNumber(getHeight()/2); addObject(new Asteroid(), x, y); } }[/code]
GUARDIAN-XGUARDIAN-X

2014/10/24

that isn't the right code, give me a moment...
GUARDIAN-XGUARDIAN-X

2014/10/24

import greenfoot.*; import java.awt.Color; public class Counter extends Actor { private int totalCount = 0; public Counter() { setImage(new GreenfootImage("Score: 0", 50, Color.WHITE, Color.BLACK)); } public void bumpSet(int amount) { totalCount = amount; setImage(new GreenfootImage("Score: " + totalCount, 50, Color.WHITE, Color.BLACK)); } public void bumpCount(int amount) { totalCount += amount; setImage(new GreenfootImage("" + totalCount, 50, Color.WHITE, Color.BLACK)); } }
danpostdanpost

2014/10/24

The code for the Counter class is the code for the Counter class regardless of the active World. You cannot 'pass' code. All code belongs to the class that it is found in, and to no other. The only things you can pass are values and objects (what is actually passed, where 'objects' are concerned, is the address in memory where the data for the object (an instance created from a class) is located. The code for the Counter class is not what you need to deal with for you issue. It is the code that defines, creates, and works with the object created from the class that is important, here.
danpostdanpost

2014/10/24

The last statement should include the code where you are trying to pass the score to the Gameover world. When supplying code, also include what class the code is in and how it relates to the World or Actor class.
danpostdanpost

2014/10/24

Please start a new discussion thread for this issue. There are multiple benefits in doing so when asking for assistance.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.