Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Scene Questions
-
Does anyone have an idea of how to make sprite collision detection using bbox or something like that to detect it? I have a sort of an idea, but I want to hear other peoples' first.
-
"What are those"? Really?
-
@Webmaster4o What?
-
Read through the scene docs, it specifically covers hit testing.
For hit-testing purposes, you can check if a Point lies within a Rect using the in operator. To check if one rectangle intersects with another, you can use the Rect.intersects() method (or Rect.intersection() if you need to know exactly where the rectangles intersect).
for enemy in enemies: if enemy.bbox.intersects(player.bbox): game_over()
For different examples, such a circle intersecting a rectangle, see the Brick game in the Examples folder, and search for hit or collision (sorry I don't have it in front of me).. If you want to check just a point you would use
in
if bullet in player.bbox: game_over
-
@JonB thank you so much. I read some, but I didn't get to that part.
-
@JonB for a different question, how would I animate a Vector2 in the scene module. That one I have been trying a ton. I used the animate() function, the run_action() function, none work with a Vector2.
-
animate a vector? A vector2 is not something you draw.......what do you mean?
I would suggest looking at the Examples/Game Tutorial, and actually work through the exercises one by one. this will show you how to animate sprites, do collision detection, etc.
-
@AtomBombed The QR code in your profile picture.
-
@JonB well I just asked because I used to make games with Lua, and it had an animation function for animating Vector2 (vec2 in Lua), and so I was just wondering.
-
Are you trying to animate the position of some object (which is described by a Vector2?), that is, have something move from one point to another in a straight line in a smooth way over time? Or are you trying to draw a Vector2 (a line with an arrowhead starting from the origin?) and have it move. Use more words to describe what you are trying to do.... maybe without using the words vector or animate:)
-
@JonB thanks for your willingness to help, but I just went about another way of doing it. Instead of having a sepereate table of each of the generated random positions for each asteroid and setting the asteroid sprite at those positions using a for loop, I just deleted that whole list worth the positions, and decided to use a list that already had the sprite objects in it making it way easier than my previous approach. I have no idea why I didn't try this first.
Really appreciate it, though.