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.

Author
Message
Behdadsoft
10
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Apr 2015 11:50
Hi.

I want make a side scrolling game and for this work I made a coin (like Arrow). now I want randomly show it in (x,y) Position.

this is my code also attached coin image, Please Guide Me how can Randomly show it.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Apr 2015 14:21
Have you tried looking at the "Random" command?

Using AppGameKit V2 Tier 1
Behdadsoft
10
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Apr 2015 14:35 Edited at: 24th Apr 2015 15:05
Quote: "Have you tried looking at the "Random" command?"


yes, Isee it and work with it at some code. and I used random for one sprite, while I have 10 sprites with arrow shape. I need do it without destroy my shape.

EDIT:

In other words, I want Randomly change My Function Position.
I know can't change function position but for better understand I said this sentence.
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Apr 2015 15:38
Can you write what you are trying to do in your own language so I can try translating what you are saying?

I don't want to cause offence but I really don't understand what you mean.

If you know how the Random command works then you can set a random position by using it very easily.

Using AppGameKit V2 Tier 1
Behdadsoft
10
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Apr 2015 15:59 Edited at: 24th Apr 2015 16:00
Quote: "I don't want to cause offence but I really don't understand what you mean."


sorry baxslash, for my bad English.

New Explanation:

1- I created a Function for make this shape with coin.



2- according to my code at below, I create a timer for call may function



when my function is calling any time, my function set (made coin shape) at same position, while I want this position to change randomly.

I don't know this explanation is clear or no.
Funnell7
7
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 24th Apr 2015 22:45
Behdadsoft, the way I would do this is by passing the random position with your function. Like so;



I would then create the first coin at this position, and then create all the other coins relative to the first coin.

For example;



Apologies, this is a very brief/rushed example, but this should give you the idea...

Using AppGameKit V2 Tier 1
IronManhood
4
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 24th Apr 2015 22:56 Edited at: 24th Apr 2015 22:59
You could do something like this.




Basically, feed the function a position, then set all the sprites positions based off of the position that was fed to the function.

Funnell7, you just did beat me to it.
Behdadsoft
10
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Apr 2015 13:46
Quote: "Apologies, this is a very brief/rushed example, but this should give you the idea..."


Thanks, No Problem.

Thanks IronManhood for example.

Login to post a reply

Server time is: 2019-08-21 21:42:40
Your offset time is: 2019-08-21 21:42:40