Maybe you should add comments about the variables TREE1, TREE2 and TREES$. Remember that not everybody is aware of your code.
Thing that i see wrong:
- Surround that code on a for-next.
- Handle other sprites (Currently, you're handling the sprite 9)
I can help you with that part of the code if you post the key.
ok i will, but i will warn you some of my code is VERY bad and its not very organised yet, just use the bar and search for "random trees" when you get it, feel free to change anything you want and i haven't changed the bottom screen the way you said you but i still will do that.
Ok, I managed to add the trees using "for". However, I saw that you're calling spset on each loop... that function should be used at the start of the game(or screen) to initialize each sprite.
I'm going to fix your code and post it tomorrow.
I have some bad news.
I tried to fix your code but there are a lot of stuff that are hard coded, management number that are reused and inconsistent game loop(You have two parts where you process inputs: One before rendering and the other after that).
The thing is that the game engine need to be done again. IDK if you want to start over but I can give you the structure to improve your project.
yeah I know, can I just have what you have done so far because I have just found out that I am going somewhere tomorrow and would like to have it as soon as possible
i am going to be completely honest with you.
i dont really understand much of what you did. i do however understand that my code was very flawed.
so what i need to do is basically set up everything but not in my main code,also i saw a big difference in speed being a ton faster,im confused,but i think i got it..?
please, do correct me if im wrong im just trying to learn the correct ways to do it
The first thing is to setup a proper game loop. As you can see, I created 4 functions: init_, input_, update_ and render_.
The game loop call input_, update_, render_ and vsync.
That way, each role is separated and the screen is the last thing that is updated on each frame (That is to avoid some unexpected behaviors).
Next, try to do a object pool to store each actor of the map. This include the chest, tree, persons, etc. Remeber to use SPSET when your object is created and then do other stuff. Also, store each management number you're using on an array to remember the sprites that are in use.
To handle behaviors create an array for the entities called behavior$.(In the game loop use "call behavior$[i]")
Finally, keep your code DRY. This mean Don't Repeat Yourself. Some guidelines:
- Try to not abuse of copy paste. If you need to do changes later, you need to change multiple parts of your code.
- Encapsulate things that look similar on def. For example, the button validation was long, so I change it for a function that check if the pointer is inside a rectangle.