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.

DarkBASIC Professional Discussion / (DBPRO, Matrix1Utils) 500 procedurally generated sprites moving simultaneously onscreen!

Author
Message
Starshyne Emir
2
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 26th Aug 2018 02:49
Ok, ok, this is not the whole of what I am planning for my game, but...

This is the source code so far, and what I want to show you is: DBPro can move LOTS of sprites even if your computer is not a very powerful machine.

In the demo, 500 2d pixel spaceships are generated, their stats are rolled and they are drawn on screen, and then they are moved accordingly to their individual movement pattern "algorithm" - yeah, each ship has its own motion pattern.

Check it out:



Yeah, I'm not Italian, but there is a lot of spaghetti in my code, because I am too lazy to indent or comment stuff, but I believe it is easy enough to understand, and you guys are smart, so there will be no problem.
[size=+2]Forever and one[/size]
Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2018 12:06
Laziness cuts both ways. If you are too lazy to make your code readable, why should we bother to try reading it? A bit of basic courtesy goes a long way on these forums - and in life generally.
Starshyne Emir
2
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 27th Aug 2018 03:52
I started coding in QBASIC about 12 years ago. None of my friends even known what programming was. I had no one to read my codes, I just needed to make them readable to myself. This is something I grew used to, I rarely indent stuff, I rarely comment, because normally I am doing everything alone. I was not intending to offend anyone when I said I didn't comment by laziness, I was just trying to play around with my own lack of style.

I took many years to learn how to name variables in a way I could know what they were supposed to do. When I learned functions, it proved to be great to me to organize my code in such way I could easily understand things without having to read tons of lines of code. Even though y code is not indented or commented, I believe it is reasonably reasy to understand because most things are named in a way they look as self-explanative as possible.

When I post here, I just copy and paste my code, exactly in the way it is written. It's just my way to say: "Hey, folks, check this out, it works and I believe it's good!" When I have a question or something is not working and I need help on fixing, I provide a simple example, commented and indented in such way it is readable - because I NEED my code to be understood. When I share my pieces of code with you, I don't NEED it to be understandable, it is something between you and my code. Any doubts I promptly will answer, I never refused to answer anything in here or anywhere else. If someone wants to know how my code works, I explain it and I do it smiling.

But OK, I will never post spaghetti code in here anymore.
[size=+2]Forever and one[/size]
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th Aug 2018 03:35
I find that if I don't comment on my code and make it as neat as possible, when I return to it (maybe years later), I find it more difficult to pick up where I left off. But hey, whatever works for you.

As to the code, I was a little surprised you didn't use constants for things checked frequently. It would be more efficient realtime to store say, the screen width() and screen height() in constant variables so that you don't have the program look up this info. Something else I noticed is that you call randomize timer() every loop iteration. I thought this was a mistake, but when I moved it before the loop it only created a few sprites and generally was weird. I didn't delve into it to figure out why it does that, but it is interesting that it is needed.

The program does what you said (though it's hard to tell if there are actually 500 sprites on the screen because it is real busy). Mine ran about 58 FPS.



So many games to code.....so little time.

Login to post a reply

Server time is: 2019-03-19 03:39:11
Your offset time is: 2019-03-19 03:39:11