#I need help on my computer science final project

1 messages ยท Page 1 of 1 (latest)

short coral
heady parcelBOT
#

<@&987246399047479336> please have a look, thanks.

heady parcelBOT
short coral
heady parcelBOT
# short coral

I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.

solemn surge
#

Can you please improve your question?
It's totally unclear what your problem is, i.e. what you expect to happen vs what actually happens, as well as a rough idea for where the error must be in the code, plus a short summary of what you have tried so far, so that we don't suggest you things to try that you've tried already.

magic ravine
#

Have you tried placing some breakpoints to follow your applicational flow?

short coral
magic ravine
#

Also please remove unused code, and don't put multiple classes in the same file.

#

And can only be drawn is vague, do you mean it doesn't get rendered, do you get an error, etc..

short coral
magic ravine
short coral
#

Is it because of the class name? Just for the record, I don't have any classes with the same name.

serene sphinx
#

its hard to help, because you havent tried pinpointing where the problem could be, yet dumped an entire project here

#

not everyone has the time to dive into a project like that to help with a single issue

#

you gotta do a bit of debugging

#

cut down the amount of code helpers have to look through to help solve the issue

short coral
serene sphinx
#

PowerUp doesnt override draw, so the implementation comes from MapObject

#

and the first check for that is java if(this.onScreen)

#

so im assuming its not rendering because onScreen is false

#

double check

short coral
#

I did but as I mentioned, the wall has exactly the same draw method and it works fine.

serene sphinx
#

they are difference instances

#

so onScreen is probably true for the wall, but not for the powerup

#

even though they derive from the same class, they are different objects

#

(this is why understanding OOP is critical)

#

the class defines what an object and can do. but a single class can be used to create many objects

#

and all those objects have their own copy of the properties defined in the class, such as onScreen

#

so even though both come from MapObject, they each have their own onScreen flag. for the wall, its probably true. for the powerup, may be false

#

never tried this in code before, but try adding this before the checkjava if(this instanceof PowerUp) { System.out.println("PU: " + this.onScreen); }

#

then run your code

short coral
#

it is printing true but it is still not rendered by my game.

short coral
serene sphinx
#

is something being rendered over it?

#

sounds like it is being drawn, just not seen

#

its using the default implementation of MapObject. others use that same implementation

#

works for others, not for this. you already checked to see if onScreen is true, and it was

#

so the next question would be: is it being obscured by another render?

serene sphinx
#

ill try running it when i get home

#

nothing seems too out of place, but also didnt spend too much time digging through the code

short coral
#

thx for helping

#

๐Ÿ‘