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 / Could you confirm my c++ function to agk translation

Author
Message
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 14th Jul 2019 19:03 Edited at: 14th Jul 2019 21:11
i translate the c++ function to Agk.
I need your help with the multi-dimensional array.
Is it a correct changeover from the c++ function to agk ?
Many thanks.

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Jul 2019 00:05
could you post the original C++ code?
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 15th Jul 2019 06:54 Edited at: 17th Jul 2019 07:39
My agk code (not yet finished, need a lot of debug to understand what's wrong.) In fact the original is javascript not c.

Attachments

Login to view attachments
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 15th Jul 2019 07:03 Edited at: 15th Jul 2019 07:05
Original code (in fact javascript)


Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 16th Jul 2019 09:07 Edited at: 16th Jul 2019 09:09
Could i convert javascript :


if (!matchtype || (currenttile.type == targettile.type)) {
}

To

If Not matchtype or (CurrentTile.Type = TargetTile.Type)
Endif

or

If matchtype=0 or (CurrentTile.Type = TargetTile.Type)
Endif
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Jul 2019 23:29
i would go with the last example.

One thing to note is that basic will evaluate ALL conditions in an if statement where C++ will evaluate left to right until it returns a FALSE condition
so

if i <= array.length and array[i] = 20

Will work in C++ when i is out of bounds and fail in basic
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 17th Jul 2019 06:43
so how to evaluate the same condition with agk ?

if i <= array.length
if array[i] = 20
end if
end if ?

Note that's finnaly javascript not c++ code.
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 17th Jul 2019 07:10
i've also this to transform to agk :

// Check if current tile has the right type, if matchtype is true
if (!matchtype || (currenttile.type == targettile.type)) {

not very familiar whis the !machtype notation in this case.

If matchtype = false or CurrentTile.type = TargetTile.type ????
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 17th Jul 2019 07:39 Edited at: 17th Jul 2019 07:43
i've updated my previous post with agk code. But it's difficult to determine what's wrong with the same colours tile detection algo and remove... Perhaps some idea ?

Note : i can't rename the forum thread title to replace c++ by 'javascript'
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 17th Jul 2019 23:08
As it's difficult for me to understand what's wrong with this code, i'll try to code something myself to detect the same colours tiles and remove them !
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 18th Jul 2019 09:23
I skimmed your code. The first thing I noticed. You use the constants TRUE and FALSE. You should change the values of them (TRUE=1 and FALSE=0). JavaScript also interprets 0, -0, NaN, NULL object all as 'false'. (I am not a Java/JavaScript expert)

The while loop in the function 'Bubble_FindCluster' is also completely different than in the original. (But shouldn't matter much)
Try it with
while ToProcess.Length >= 0

With Target_tile = Bubble_niveau.Tableau_tiles[tx,ty] you create a copy of the tile from the table. The values you change there will not be changed in the source. (Target_tile.bProcessed = TRUE). So you should copy Target_tile back so that the changes take effect.

Maybe this will help a Little.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 18th Jul 2019 20:28
Many thanks for your help blink0k and MadBit.
it's interesting to have our advice.
i should be tired to put TRUE to 0 and FALSE to 1 !

Now i'm coding my own function to detect the clusters.
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 18th Jul 2019 22:52 Edited at: 19th Jul 2019 08:37
i've coded my own 'delete same color clusters function... Bubble_findcluster (Tile_colonne as Integer, Tile_rangee as Integer)

sometimes it not works exactly as expected ... but better !

Next Step : Erase the floating clusters !



Attachments

Login to view attachments
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Jul 2019 00:21
Not yet perfect.

Login to post a reply

Server time is: 2024-11-22 16:06:33
Your offset time is: 2024-11-22 16:06:33