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

jabirfatah91's Comments

Back to jabirfatah91's profile

OHH! Those were helpful for me too. But more questions has been discovered. Form the "Board" class. 1. What does "addArray" method do? 2. What does this line "System.arraycopy(snake, 0, newSnake, 0, snake.length);" mean? 3. What the sign "<>" is used and what the line "List<Item> item = getObjects(Item.class);" does actually? From the "Item" class: 1. by referring this line "Actor item = getOneIntersectingObject(Wall.class);"- why "Wall.class" is used to get an intersecting object? Souldn't it be "Snake.class"?
Hi does your snake consist of two body segments from the game starting?
Okay!! Thanks! Can you please explain these codes in your ball class for me ? (is given below): import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Ball here. * * @author (your name) * @version (a version number or a date) */ public class Ball extends Actor { /** * Act - do whatever the Ball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ //double power = 30; //private double angle = 30; private double h0 = 1; private double h = h0; private double tStart; private double xStart; private double yStart; private double g = 30; private double SCALE = 7; double v0y; double v0x; private boolean first = true; public Ball(int angle, int power) { v0y = power * Math.sin(Math.toRadians(angle)); v0x = power * Math.cos(Math.toRadians(angle)); } public void act() { if(first) { first = !first; tStart = System.currentTimeMillis(); xStart = getX(); yStart = getY(); } else { double t = (System.currentTimeMillis() -tStart) / 1000; h = h0 +(v0y*t) - ( (g*t*t) / 2); setLocation((int)(xStart + SCALE * (v0x*t)),(int)(yStart - SCALE *h)); } removeBall(); } public void removeBall() { World background = getWorld(); if (getY() > background.getHeight()) { background.removeObject(this); } } } Question 1: Why do we need "private double" here? 2: "private boolean first = true"- what is this for? 3: first = !first; tStart = System.currentTimeMillis();- what does those codes mean? and what does "TimeMillis" do here?
OOps!! Correction: And dude, isn't it possible to add a message which can tell me if the target was HIT or not?
And dude, isn't it possible to add a message which can tell me if the target was hot or not?
Good!! Is there any special reason to use moving/scrolling star as your Target? Isn't it okay if I use any fixed target which is not moving?