Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Is exitfunction the equivalent of return in c

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 17:37
Is exitfunction the equivalent of return in c?

In C
The return statement terminates the execution of a function and returns control to the calling function. Execution resumes in the calling function at the point immediately following the call.

It seems with the exitfunction the execution doesn't always resume the point following the call

please correct me if im wrong just got an issue with trying to do recursions
fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 17:47 Edited at: 5th Aug 2018 17:58
This example seems to work with its recursion properly


but the recursion seems to get in an endless loop with this example and/or exits the main loop


and not sure why
fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 19:29 Edited at: 5th Aug 2018 19:40
Ive just checked and it seems to be not going past the first floodfill4

drawLine(x,y,x,y,newColor,newColor)
floodFill4( w, h, x + 1, y , newColor) //loops on here (or gets stuck for somereason
floodFill4( w, h, x - 1, y , newColor) // when it hits this one- the current X will be W wont it but then the point check if the point is green then it Exit Function and goes through the one above and this one again during the loop
floodFill4( w, h, x , y + 1, newColor)
floodFill4( w, h, x , y - 1, newColor)

Ill have a think and get back to you

So what I think its doing is moving X :-

10 to W
W to 10
10 to W
W to 10
etc
etc
maybe put some checks in there to say if the first flood full of going >>> as been completed then dont do this function on this Y line again
if move Y line - then reset the checks

Oh the joys of beautiful programming
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 19:51 Edited at: 5th Aug 2018 20:02
Think ive worked out the problem but not the solution

If you comment out 3 of the floodfill lines it seems to kinda work
and what i figure the problem now is the point function to get the color at a point




as its now exiting but not doing anything which im putting it down to clearing the screen lol im sure its just me doing something wrong
but that would mess up the way the recursions would work anyway im sure the point function aint helpiung
fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 20:04
may have to use an array for storing the old color values

then this function using the array instead of point might work



fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 20:06
For that one you are going into FloodFill4 once... so maybe add the recursion back in



But you still getting stuck on those X's - the check doesnt go past when it goes to W and back to 0
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 20:24
no drawing being shown but it does complete with this one

fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 20:28
Just checked and the FPS is rocking at 0.1-0.5 doing this process thats why its boooming

try the W and H from 100,100 to say like 15,15
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 20:34 Edited at: 5th Aug 2018 20:35
yeh I think need to store the color of each screen coord in an array the last example don't boom atleast

the w and h is really just a way of restricting the floodfill to an area




is quite fast just don't display the lines
fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 20:36
Try



Then put your point check in to skip a point
puzzler2018
User Banned
Posted: 5th Aug 2018 20:38
Just wondering if there is a limit on AppGameKit for recursive functions? it booms still if W or H is >80 mark
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 20:46 Edited at: 5th Aug 2018 20:57
Quote: "Just wondering if there is a limit on AppGameKit for recursive functions?"


Theres something like that im sure had similar issues in the past and I gave up thinking maybe recursions didn't work
but then the fractal tree algorythm proves recursions works

thanks anyway might just have to work on a completely different method really just thought a floodfill could come in handy
and recursion is the neatest and most readable method

The original recursive method but using the screen array (works but falls over if w or h too high as well)
fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 21:08
Its nothing fancy but this draws a white ellipse and then fills it with green



puzzler2018
User Banned
Posted: 5th Aug 2018 21:34 Edited at: 5th Aug 2018 21:40
10000 Faster





EDIT

Got the wrong way round on checks



Enjoy

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Aug 2018 22:00 Edited at: 5th Aug 2018 22:16
that gave me an idea to test the floodfill method to see if it was working as expected




its almost like it never goes left of the spot but atleast it don't crash just have to wait and see if theres some limit

which gives me an idea of replace color with another color in a memblock image not that hard to do but not so sure how useful lol
fubar
puzzler2018
User Banned
Posted: 5th Aug 2018 22:21 Edited at: 5th Aug 2018 22:22
Ive got this so far



Click any where - it should turn everything green which is the same pixel as you ciick on
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Aug 2018 02:29
I had to change
offset = ((((y*4)* 1024)+x*4)) + 12
to
offset = ((Y*1024)+(X*4))+12

otherwise I get memblock out of range error at line 69
fubar

Login to post a reply

Server time is: 2024-11-23 18:22:04
Your offset time is: 2024-11-23 18:22:04