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 / my most recent post

Author
Message
Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 20th Feb 2014 17:29
on my most recent post I realized that I had given you guys that wrong code. I cannot edit my post yet because they have to approve of it, and I won't be able to edit my post before (I'm assuming) someone posts on it. I will try to edit my post when I get home, but as of now, here is the actual code:


I realize this is extremely long, but I am not sure exactly what someone would need to help me. thanks!

ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 21st Feb 2014 17:53
Well, it seems to work for me. Are you sure the program doesn't just need very long to load all the files?

Also, no offense really, but the code looks disastrous. For instance, this part:



Did you write that all manually?

All I can say is check out arrays and functions. They will make your life (and coding) so much easier and more efficient. While the documentation certainly isn't the best, these things are explained there (press F1 inside the editor and select Principles). Alternatively there are a few tutorials on this site.

Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 21st Feb 2014 18:44
Wow... that's long.
Maybe attach your .dba file next time instead of pasting?

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Feb 2014 20:06 Edited at: 21st Feb 2014 20:11
Ok, I'm going to show you the benefit of recognizing patterns in your code so you can reduce the redundant bits.

For instance, take this 286 lines of code:



Now, it's only 27 lines:


Just to explain a little bit, the part if k = 22 then exit is because the loops will actually iterate 24 times, but we only need 22. So once all 22 objects are created, exit the loop early.

When creating the objects, let's use an array to store the IDs. I noticed you use two objects together in parallel so we'll need to keep track of 2 IDs for each set. Instead of two arrays, we'll create a UDT and define the array as such:




You can then delete these 44 lines:



Because you have no need to store those values since you're only use them to increase the object's angle by 90 degrees from it's current angle.

Let's look at this code here:



Let's simplify it and use our array. First, instead of checking both upper and lower case letters, just convert the inkey character to upper. Then we'll convert that uppercase letter into a number according to the ascii chart. The capital A starts at number 65, so that's what we subtract from the number to get 0, the first element in our array.

Now we can delete yet another 110 lines of code for checking key events and replace with using only these 5 lines of code:



So we've simplified your object creation code and the code for checking key states. So how about the object collision? You can use a FOR loop and the arrays to greatly reduce that code as well. All you got to do is find the pattern.


As for your initial problem, the reason it appears the program hangs up (it's not actually) when you click new game is because you're not calling sync anywhere inside the loop you have in the MainSection routine. Add sync at the bottom just before you call LOOP and you should see your objects.

Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 24th Feb 2014 17:29
Quote: "As for your initial problem, the reason it appears the program hangs up (it's not actually) when you click new game is because you're not calling sync anywhere inside the loop you have in the MainSection routine. Add sync at the bottom just before you call LOOP and you should see your objects.
"

Wow... thank you so much. We had thought we had a sync down there, but I guess we didn't. Thanks! And also, we are currently trying to clean up our code. This wasn't my code, it was ,my friends and he asked me to help him but when I couldn't I asked you guys. So thank you all very much!

Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 25th Feb 2014 17:10
Quote: "When creating the objects, let's use an array to store the IDs. I noticed you use two objects together in parallel so we'll need to keep track of 2 IDs for each set. Instead of two arrays, we'll create a UDT and define the array as such:"


SO I understand what you are trying to say, it makes perfect sense, but we are unsure of how to make the arrays correctly. (we are just doing this for a elective class in school and we are not extremely advanced)Is there any way of showing us/telling us how to do something like this?

zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 26th Feb 2014 03:07 Edited at: 26th Feb 2014 03:16
Create the type:

Then create the array as the type you just created:

Then access the array and it's data by:


So all together, you could have something like this:

Be sure to declare the new type somewhere in the code above where you use it. I suggest having all of your types at the beginning of your code.


Edit:
You can also create types that are not arrays. I usually create a mouse type at the beginning of my code with an updateMouse() function called at the beginning of my loop:



Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 3rd Mar 2014 17:25
@zeroslave so I created the array code that replicated my game. I was able to create all the rotating cubes(the ones that have the arrow texture), but I tried making the invisible objects that go along with the rotating cubes, (objects 1000-1021) but it didn't work here's what I have so far.

Any help?


Login to post a reply

Server time is: 2026-07-06 04:30:30
Your offset time is: 2026-07-06 04:30:30