Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Need help with breakout (greenfoot)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
gameyoda
Expert Cheater
Reputation: 0

Joined: 06 Oct 2006
Posts: 150

PostPosted: Mon Dec 07, 2009 3:21 pm    Post subject: Need help with breakout (greenfoot) Reply with quote

Hello,
I have been trying to make breakout in greenfoot (starting with the basic program at http://www.greenfoot.org/scenarios/).
The problem is I dont know how to add health to my blocks. I tried going into ball as the blocks are deleted there and calling a self made method from brick, but it says it doesnt know brick and actor doesnt have the method I tried to call.
What I added to ball:
Quote:
if (actor instanceof Brick)
{
brick.geraakt();
if(brick.getHitpoints() <= 0)
{
world.removeObject(actor);
world.checkIfWon();
}
}


What the basic class contained was just:
Quote:
world.removeObject(actor);
world.checkIfWon();

(Im dutch and geraakt means hit incase you wondered why I chose that name Wink)

The code for the method geraakt in brick:
Quote:
public void geraakt()
{
hitpoints--;
}

public int getHitpoints()
{
return hitpoints;
}


hitpoints is an integer variable I made that starts out with the value 1 and when the brick is hit it goes to 0 and should be deleted (I made that in Ball as seen above).

In case you want it, greenfoot is downloadable from: http://www.greenfoot.org/download/
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Mon Dec 07, 2009 4:07 pm    Post subject: Re: Need help with breakout (greenfoot) Reply with quote

gameyoda wrote:

The problem is I dont know how to add health to my blocks.
Quote:
public void geraakt()
{
hitpoints--;
}


I'm not sure what your question/problem is but hitpoints--; decreases the hitpoints, and hitpoints++; will increase the hitpoints.
Quote:
public void VoegHealthToe()
{
hitpoints++;
}



Quote:
if (actor instanceof Brick)
{
brick.geraakt();
if(brick.getHitpoints() <= 0)
{
world.removeObject(actor);
world.checkIfWon();
}
}

I don't know what 'actor' is, but don't you mean world.removeObject(brick) if you want to remove the brick.
Back to top
View user's profile Send private message
gameyoda
Expert Cheater
Reputation: 0

Joined: 06 Oct 2006
Posts: 150

PostPosted: Mon Dec 07, 2009 11:59 pm    Post subject: Reply with quote

I know that hitpoints-- decreases it, thats what I wanted and when its at 0 the brick gets deleted. The question is how do I get greenfoot to anknowledge its a brick?
and I do want world.removeObject(actor); to be with actor, because thats how I started off (with what I downloaded). The only problem is that I cant call upon methods of the actor (which is a brick).

edit: nevermind, found the problem. I needed to make the actor a brick.
Thanks for the help though.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites