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.

Android / Broadcast Random() - Bug or lack of knowledge

Author
Message
HYDRAK
3
Years of Service
User Offline
Joined: 9th Sep 2020
Location:
Posted: 16th Sep 2020 20:29 Edited at: 18th Sep 2020 01:54
Hi guys i m a noob in programming. I also try to find a similar topic but with no luck. I can't solve a problem that i have, i try to create s sprite in a random X,Y position. The problem is that the code i write work properly in the windows window but when i broadcast to the mobile (Android) the sprite is always in the same position... i leave the code:

Thank you for your time!

MOD EDIT: Code tags make things easier to read
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Sep 2020 20:12 Edited at: 19th Sep 2020 08:07
HYDRAK,

welcome to the first step of your programming adventure

the answer to your title's question is "B" (IE, it's not a bug) andSEE BELOW i urge that you review the Getting Started Guides to re-establish your foundation.

the free 8 chapter Extract found here is also a good source for beginning AGK. i expect that THIS is an updated version of that, for Studio, as well.

perhaps someone else might have the energy to address your code, which has many issues including your loops, basic variable usage, etc, line by line, but it's not something i'm up for.

but, please don't be discouraged, and do push forward. we were all where you are now (the "beginning") and continued the adventure to find much enjoyment once we tripped over obstacles a few (thousand?) times

BTW, the core of what you're trying to do is basically fine:

i expect that when you broadcast that, you'll find the same?
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
HYDRAK
3
Years of Service
User Offline
Joined: 9th Sep 2020
Location:
Posted: 18th Sep 2020 01:36
Hi Virtual Nomad,
First thank you to find the time for answer me!! Is nice to know that isn't a Bug lol This means that the problem is in the piece of code that I write, my bad Don't worry at all , if someone will found the time for address my code will be for sure helpfully, I already found your answer very helpfully and I recently start to read today those links. Also if someone a my stage read this post, take a look a : https://www.appgamekit.com/documentation/language.html

I will keep push Starting to code remember me the first time ever i lunch blender, gimp, nifscope with the target to create a mod, have take time for sure but also the first 3D model fully working have give same very enjoyment times !! And completing the mod even more

About the code, yes it work perfectly, in both window mode and broadcast.
I will finish to read same guides, and i rewrite everything

Thank you for your time!!

Ps. I found very helpfull all the tutorial that Rick have made on youtube, everythinck i learn about programming I have to really thank Rick, for make AppGameKit series and for the time for make those video... So if you know Rick, thans him for me !!
Pps. Sorry for don't use the code tag, I haven't completely seen it, for sure make post short and more readable
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Sep 2020 01:56 Edited at: 18th Sep 2020 01:57
Quote: "the first time ever i lunch blender, gimp, nifscope "

then you know all about perseverance. blender still intimidates me (i just revisted it - the tutorial vid i attempted to watch went on and on about all the "handy" shortcuts/interface options which put my mind in a headlock, causing me to give up, again!), so you're up on me, there

Quote: " Sorry for don't use the code tag"

that wasn't my edit but it helps others read the code which will only help others help you. i've since edited it, again, by including the lang=AGK Syntax to make it even more readable. (see my Sig re: CODE tags)

with that, i don't know how you copied the line numbers in but that's a hindrance. post code that we can simply copy and paste into the IDE to test/run for ourselves.

IE, i pasted your code, then had to manually remove the line numbers, then remove reference to the sprite images , etc, etc.

forward. always forward!
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
HYDRAK
3
Years of Service
User Offline
Joined: 9th Sep 2020
Location:
Posted: 18th Sep 2020 17:09 Edited at: 18th Sep 2020 17:23
Yeaah Perseverance is the key!
With blender i m a step one too lol I been luck and unlucky in my small project, i was create a mod for Oblivion, that use .nif file, and the support for those files is always been low.. so I ended up with 8 different version of blender in my pc, using the last version to make the poly mesh and use the other version to add collision,hull,physics etc etc.. The latest versions of blender can be scare , with unlimited windows, options, interfaces, but learning a bit the shortcuts have help me a loot and also start from a very easy task, create a 3D mesh from a imagine.. if you like I can spoiler here or send you with PM a list of which tutorial help me most.

About the line and number..eeehm.. i manually write them lol but for know on I will definitely use the tag, thank you for show me that

About the code, I figured out that more or less work, the strange thing is just that when I broadcast, all the random X and Y position they been calculated always in the same order, let's day that the 1' Hdog is a X=10 Y= 2, the 2' is a X=50 Y=32, the 3' is a X=12 Y=9.... all the time i restart the app they always appire in the same order. But in window mode all the time I start the app all the Hdog appire in a different position, and also each one of the sprite are always in a different place... By the way is just a project to get familiar with same basic command and language syntax, but if I can understand why will help me for sure lol
Another question that I have ,is about how can I set the app to "automatically" proportion all the Imagine/Sprite to adapt a the right proportion to different Mobile devices, In the code i make sure to calculated W and H and use them the same proportion on the different phones and tablets... I wonder if there is a easy way maybe, or a command that do that or if I am on the right way..

Thank you for your time
Always forward and CHAAAAAARGEEEEE

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Sep 2020 23:25 Edited at: 19th Sep 2020 00:32
Quote: "the strange thing is just that when I broadcast, all the random X and Y position they been calculated always in the same order"
i don't know what broadcast does differently but i'll suggest 2 things that both seemed to work (and, yeah, i saw the same pattern that you did):

1) set the Random Seed each time you re-spawn Hdog. something like:

2) use Random2() instead where it is "slower than Random but produces better quality randomness over a larger range of values".
  • i don't know how "larger range" is defined but it seemed to make a difference


>> i've stricken the first suggestion that doesn't seem to help, on further testing

meanwhile, i've changed this thread's title to something a bit more helpful for Search purposes.

add: some searching revealed THIS re: Broadcast vs Random().
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
HYDRAK
3
Years of Service
User Offline
Joined: 9th Sep 2020
Location:
Posted: 19th Sep 2020 02:27
Boom thank you so much I was ignore both command. More knowledge on the way

[/quote] i've changed this thread's title to something a bit more helpful for Search purposes.[quote=]

Perfect!! Is much better so maybe the topic cap help someone else too

The random2() work perfectely
I feel happy about this small test/project, is a very very very simple mini-game but have same basic stuff in it, now i can carry one to discover more stuff, guides and tutorial! And start to use arrays...

Thank You again

Complete:
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 19th Sep 2020 07:24 Edited at: 19th Sep 2020 08:08
2 things:

1) i retract my previous opinion of whether or not this is a bug, and 2) have since reported it, as such.

thanks, hydrak, for bringing this (back) to light
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
HYDRAK
3
Years of Service
User Offline
Joined: 9th Sep 2020
Location:
Posted: 19th Sep 2020 16:37 Edited at: 19th Sep 2020 16:58
I'm glad to give a small contribute to the community

Thank you for your time and for what you teach me

Login to post a reply

Server time is: 2024-04-16 15:46:18
Your offset time is: 2024-04-16 15:46:18