Detecting collision of two sprites that can rotate [duplicate]

A lot will depend on how you are managing your objects, but… import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.KeyStroke; import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public … Read more

Collision between masks in pygame

The mask for the Terrain is never set. Crate a proper Terrain mask: class Terrain(object): def __init__(self, x, y): self.x = x self.y = y maskSurf = pg.Surface((display_width, display_height)).convert_alpha() maskSurf.fill(0) pg.draw.rect(maskSurf, (160, 160, 160), (self.x, self.y, display_width, 500), 0) self.mask = pg.mask.from_surface(maskSurf) print(self.mask.count()) # […] When using pygame.mask.Mask.overlap(), then you’ve to check the overlapping of … Read more

How to deal with symbol collisions between statically linked libraries?

At least in the case of static libraries you can work around it quite conveniently. Consider those headers of libraries foo and bar. For the sake of this tutorial I’ll also give you the source files examples/ex01/foo.h int spam(void); double eggs(void); examples/ex01/foo.c (this may be opaque/not available) int the_spams; double the_eggs; int spam() { return … Read more

C++ console app with two colliding objects not Working [closed]

This wild beast of human imagination delete ship1, ship2; deletes ship2, but doesn’t delete ship1. Comma here is treated as sequence (comma) operator, and result of such expression is result of last sub-expression. Your function always returns 1. You probably meant something like this int shipdetcol(spaceship &ship1, spaceship &ship2, float colrange) { return colrange > … Read more