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.

Newcomers AppGameKit Corner / [SOLVED] help with spawning clouds

Author
Message
merkzilla
User Banned
Posted: 31st May 2020 17:05
im trying to make a max of 5 clouds spawn and travel across the screen right to left, also i want each new cloud that spawns to have a random image and speed. ive written this code from the top of my head with no success in seeing any clouds all though it doesnt produce any errors ( a big improvement for me) it still isnt working heres the short version but ive included the project in the upload aswell

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 31st May 2020 20:43 Edited at: 31st May 2020 20:47
Your code is difficult to read, and the project that you gave is not compiled due to the lack of declaration of the mainmap_mapone variable. You are probably just tired.
Try to simplify the code.



to



I would rewrite everything from scratch by changing the approach.
merkzilla
User Banned
Posted: 31st May 2020 21:20
thank you Qugurun im thinking i should take a break for a while too lol
merkzilla
User Banned
Posted: 1st Jun 2020 00:04
so i went down just loading one cloud without everything else. it places one cloud in the top left corner but it comes up with an error sprite 100002 does not exist in main.agc at line 24
merkzilla
User Banned
Posted: 1st Jun 2020 00:25
i dont think my other post went through sorry if its waiting for approval maybe but i fixed that problem but now when i try to create the fifth sprite using cloudmove[5] it tells me array index out of bounds; index 5, array length 4 in main.agc at line26
Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 1st Jun 2020 02:04 Edited at: 1st Jun 2020 03:47
so that you can change the texture of the clouds, you need to always have the same texture size or change the size of the sprite before loading a new texture into it.
try not to use gosub in large projects this may cause no convenience.

See how it works and use ScreenToWorldX() to convert coordinates or GetViewOffsetX()
Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 1st Jun 2020 03:55 Edited at: 1st Jun 2020 03:56
This post has been marked by the post author as the answer.
merkzilla, I just saw your posts now.
The array is counting from 0.

And I edited the previous answer adding the camera offset GetViewOffsetX ()

merkzilla
User Banned
Posted: 1st Jun 2020 14:49
oh yes i forgot the count starts at 0 and the clouds dont seem to move when i add it to my main code do you think these two are interfering


Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 1st Jun 2020 17:52 Edited at: 1st Jun 2020 17:52
https://forum.thegamecreators.com/thread/226373#msg2656367 It works.

You are probably missing something.
And about the question. These two do not interfere.
JosephB
14
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 1st Jun 2020 19:04
merkzilla,

Remove or rem-out your command words "do" and "loop" in your playermove sub-routine and any other sub-routine as these prevent other code from running.
merkzilla
User Banned
Posted: 1st Jun 2020 19:37
Ok thank you both I will look at the code again after work. I guess another question is if I have two types with createsprite(0) then a for i = 1-5.... Would they both create sprite 1-5 that would interfer with each other or does the code read it as separate sprites
Scraggle
Moderator
17
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Jun 2020 19:51
That question makes no sense.
Look at the help files for CreateSprite() and see how you need to assign an ID (or have one assigned in a variable) and you will see why your question makes no sense.

Login to post a reply

Server time is: 2020-09-30 17:33:48
Your offset time is: 2020-09-30 17:33:48