### [seemingly] Random MAV?

UserMessage
Posted : Thursday, 31 July 2008, 13:41 | Permalink
spinal

 [backstory] Jay's B&W entry a couple of weaks ago got me thinking about that mouse-string code i posted a while ago, so i started tweaking it a bit. Upon Jay's suggestion, i have added actual 'body' segments instead of a simple line, creating a sort of caterpillar. Anyhow, i had a quick attempt at rotating the images (im planning on adding legs) but i keep randomly getting a MAV on the RotateImage line. Can anyone have a go at explaining the problem to me, it seems totally random, just leave the thing sitting in the middle of the screen for a while and 'ding!' MAV!. ; Mouse string, spinal. Graphics 640,480,0,2 Global tail_len = 160 ; pixel length between the nodes (10 * what we need) Global tail_nodes = 15 ; How many sections the tail is Dim nodes_x(tail_nodes) ; X position of each node Dim nodes_y(tail_nodes) ; Y position For x=1 To tail_nodes nodes_x(x) = MouseX()*10 nodes_y(x) = MouseY()*10 Next HidePointer Global body_part = CreateImage(16,16) SetBuffer ImageBuffer(body_part) Color 0,255,0 Oval(0,0,16,16,1) Color 255,0,0 Oval(1,1,14,14,1) Color 0,0,0 Line 0,7,15,7 Line 0,8,15,8 SetBuffer BackBuffer() Repeat Cls move_tail() Flip 1 Until KeyHit(1) End Function move_tail() nodes_x(0) = MouseX()*10 nodes_y(0) = MouseY()*10 For x=1 To tail_nodes rotation = ATan2(nodes_y(x)-nodes_y(x-1),nodes_x(x)-nodes_x(x-1)) pos_x = nodes_x(x-1) + tail_len * Cos(rotation) pos_y = nodes_y(x-1) + tail_len * Sin(rotation) nodes_x(x) = pos_x nodes_y(x) = pos_y x1 = nodes_x(x-1)/10 y1 = nodes_y(x-1)/10 x2 = nodes_x(x)/10 y2 = nodes_y(x)/10 gfxTemp=CopyImage(body_part) MidHandle gfxTemp RotateImage gfxTemp,rotation DrawImage gfxTemp,x1,y1 Next End Function --> |edit| I cant spell and im not allowed to change the title |edit|-----Download "Don't Flip Out!" Directly to your OUYA! (Click Here).
Posted : Thursday, 31 July 2008, 14:54 | Permalink
mindstorm8191

 You should try outputting the values you're feeding into the RotateImage command, before you execute it, plus the size of the image. You can send it either to file or debuglog. Then the last value will be what caused the error, or proof that there is something wrong with the command.-----Vesuvius web game
Posted : Thursday, 31 July 2008, 14:57 | Permalink
Jayenkai

WW Entries : 106
 The line "gfxTemp=CopyImage(body_part)" creates a copy of the image.. The line "" doesn't get rid of it again.. Just keeps copying and copying, and using more and more memory! "FreeImage gfxTemp" at the bottom of the clump would free things up. But, a better way to do it would be to pre-rotate (say) 64 rotations, and just use those instead of constantly re-rotating them..-----"Load, Next List!"
Posted : Thursday, 31 July 2008, 15:20 | Permalink
Eikon

WW Entries : 7
Posted : Thursday, 31 July 2008, 15:44 | Permalink
spinal

 thanks guys, it works fin using pre-rotated segments. ; Mouse string, spinal. Graphics 640,480,0,2 Global tail_len = 160 ; pixel length between the nodes (10 * what we need) Global tail_nodes = 15 ; How many sections the tail is Dim nodes_x(tail_nodes) ; X position of each node Dim nodes_y(tail_nodes) ; Y position For x=1 To tail_nodes nodes_x(x) = MouseX()*10 nodes_y(x) = MouseY()*10 Next HidePointer Global body_part = CreateImage(16,16) SetBuffer ImageBuffer(body_part) Color 0,255,0 Oval(0,0,16,16,1) Color 255,0,0 Oval(1,1,14,14,1) Color 0,0,0 Line 0,7,15,7 Line 0,8,15,8 TFormFilter 1 Dim img(35) For n=0 To 35 img(n)=CopyImage(body_part) RotateImage img(n),n*10 MidHandle img(n) Next SetBuffer BackBuffer() Repeat Cls move_tail() Flip 1 Until KeyHit(1) End Function move_tail() nodes_x(0) = MouseX()*10 nodes_y(0) = MouseY()*10 For x=1 To tail_nodes rotation = ATan2(nodes_y(x)-nodes_y(x-1),nodes_x(x)-nodes_x(x-1)) pos_x = nodes_x(x-1) + tail_len * Cos(rotation) pos_y = nodes_y(x-1) + tail_len * Sin(rotation) nodes_x(x) = pos_x nodes_y(x) = pos_y x1 = nodes_x(x-1)/10 y1 = nodes_y(x-1)/10 x2 = nodes_x(x)/10 y2 = nodes_y(x)/10 rot=rotation/10 If rot>36 Then rot=rot-36 If rot<0 Then rot=rot+36 DrawImage img(rot),x1,y1 Next End Function --> -----Download "Don't Flip Out!" Directly to your OUYA! (Click Here).
Posted : Thursday, 31 July 2008, 17:09 | Permalink
steve_ancell

 Spinal, both of your programs on this thread seem to be working OK on my computer. BTW... That looks fun, what are you making Bud ?.
Posted : Thursday, 31 July 2008, 17:14 | Permalink
spinal

Posted : Friday, 01 August 2008, 01:14 | Permalink
shroom_monk

WW Entries : 8
 "steve_ancell" Spinal, both of your programs on this thread seem to be working OK on my computer. Well, given what Jay said, maybe your computer has enough memory not to run out of space... or you just didn't run it for long enough to run out of memory...-----A mushroom a day keeps the doctor away... Keep It Simple, Shroom!
Posted : Friday, 01 August 2008, 08:01 | Permalink
steve_ancell

 Hmmm, good point. Well spotted Shroom . I had it running for about 2 minutes, and I have 512 MB RAM. I take it that 2 minutes is not long enough.
Posted : Thursday, 05 January 2012, 10:21 | Permalink
spinal

Posted : Thursday, 05 January 2012, 13:27 | Permalink
Afr0

WW Entries : 3
Posted : Thursday, 05 January 2012, 14:57 | Permalink
Jayenkai

WW Entries : 106
 *sigh* I really need to get the upstairs PC working again.. I'll have a look at it in the morning, Spinal. -----"Load, Next List!"
Posted : Friday, 06 January 2012, 01:55 | Permalink
spinal

 Forget the jittering, reuploaded... Title using a map now. However my scroll speed is all wrong, I'm a little out of practice, but from what I can tell, it should be right -----Download "Don't Flip Out!" Directly to your OUYA! (Click Here).
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 650|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsSpinal's Search for Tech steve_ancell Thu 02:12 NoSex in England GfK Wed 15:22 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
Jayenkai
Thu, at 02:21
steve_ancell
Thu, at 02:12
spinal
Thu, at 01:42
shroom_monk
Thu, at 01:16
zzoom
Thu, at 00:30
rockford
Wed, at 23:32
Kuron
Wed, at 23:24
therevillsgames
Wed, at 18:54
Sammy
Wed, at 18:38