Code Snippets > Collisions and Physics ( Created 06 March 2009 | Last Edited 06 March 2009)

 Box/Circle collisions by Jayenkai | No VotesReally really simple bog standard collisions.. Written inBlitz Graphics 800,600,32,2 SetBuffer BackBuffer() Repeat Cls Oval MouseX()-32,MouseY()-32,65,65,0 Rect MouseX()-32,MouseY()-32,65,65,0 Color 255,255,255 If Sqr(((100-MouseX())*(100-MouseX())) +((400-MouseY())*(400-MouseY())) )<65 Then Color 255,0,0 Oval 100-32,400-32,65,65,0 Color 255,255,255 If Abs(700-MouseX())<65 And Abs(400-MouseY())<65 Then Color 0,0,255 Rect 700-32,400-32,65,65,0 Flip Until KeyDown(1) --> Just your basic bog standard collision stuff. Box vs Box = Abs(x) and Abs(y) checks. Circle vs Circle = Sqr((x*x)+(y*y)) check. (Pythagoras) Probably useful for folk!

There are no comments for this entry. -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 646|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsNoSex in England GfK Wed 15:22 Spinal's Search for Tech rockford Wed 14:45 Happy Birthday, Windows XP Jayenkai Wed 08:40 What Have You Done? - Oct 2016 GfK Wed 08:21 GoPro Hero 4 Silver vs Nikon KeyMission 170 Jayenkai Wed 01:51 Rhythm Heaven Megamix Kuron Wed 01:46 RIP - Bobby Vee Kuron Wed 01:36 El Stompo Jayenkai Tue 04:59 RIP - Pete Burns Jayenkai Mon 18:55 NerdBlock Jayenkai Mon 16:40 More

 Latest Items Blog : Spilling my Noodlessteve_ancell Mon 13:38 Link : Character generators! :DAfr0 Sun 07:58 Woot : Getting Noticed... for Gameboy Dev!Afr0 Sat 17:17 Dev-Diary : 1st Ever Wed Workshop Progresszzoom Thu 23:12 Showcase : Biomorph FractalsAndy_A Wed 12:43 Snippet : Fisheye Lens EffectJayenkai Wed 11:50 Snippet : 2D BallsJayenkai Wed 06:22 Showcase : Mining Map AI DemoStealth Tue 19:41 Showcase : Biotic Limit - Games For Better (2 Days) Editionrychan Mon 12:27 Dev-Diary : Intellivision Controller Adapterspinal Sun 11:33 Snippet : Contour Map from DataHoboBen Fri 18:14 Snippet : FPS Control (WASD+Mouse)Pakz Wed 22:30 Article : Concurrency in C#Afr0 Sun 12:28 News : Newsletter #281HoboBen Fri 04:18 News : Newsletter #280Jayenkai Sat 05:10More

Who's Online
rockford
Wed, at 22:47
therevillsgames
Wed, at 18:54
Sammy
Wed, at 18:38
Wed, at 17:58
Krakatomato
Wed, at 17:25
Pakz
Wed, at 17:20
zzoom
Wed, at 16:47
Jayenkai
Wed, at 16:32
GfK
Wed, at 16:30
spinal
Wed, at 14:19