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

2019/7/19

User writing and making the character move

1
2
danpost danpost

2019/7/23

#
Scarley wrote...
is there anyway to make the command tab bigger? or add a command log where i can set at least one example so the user can kind get an idea on what to do?
Bigger? -- no; not if you are to use Greenfoot.ask. I think the only way would be to use a separate actor to collect the input (like a dialog frame with an input box). Well, this is the OTHER way, which you probably would not want to do (put the game world in an actor and use the main world for the input -- again, like a dialog box).
Scarley Scarley

2019/8/7

#
Thanks thanks, so now i wanted to make it so if i hit the wall my character woudl stop, i did sometjhing like this http://prntscr.com/opcjy5 which worked when i did in the player actor script, but now that i tried in the myworld one i get this error, how can i fix this?
danpost danpost

2019/8/7

#
Scarley wrote...
Thanks thanks, so now i wanted to make it so if i hit the wall my character woudl stop, i did sometjhing like this http://prntscr.com/opcjy5 which worked when i did in the player actor script, but now that i tried in the myworld one i get this error, how can i fix this?
It is not your world that would hit a wall (and the hitWall method is not in your world class).
Scarley Scarley

2019/8/8

#
Oh i see, is there anyway to make this work?
danpost danpost

2019/8/8

#
Scarley wrote...
Oh i see, is there anyway to make this work?
Probably just:
if (player.hitWall())
Without player, it is equivalent to:
if (this.hitWall())
where this refers to the World object, being it is coded in your World subclass. So, you have to specify the object that can hit a wall if is not your World object.
Scarley Scarley

2019/8/12

#
Well i tried with
if ("hero_moveleft();".equals(command)) player.setLocation(player.getX()-20, player.getY());if (player.hitWall() == true){player.setLocation(player.getX()+20, player.getY()); } 
and its working perfectly, if only i could show like a list with what commands the user typed so he could know a little bit of the sintax to write a program , but its already good enough, thanks for the help
You need to login to post a reply.
1
2