Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays
Using Loops or Arrays Using Loops or Arrays
Using Loops or Arrays
Go Back  Xtreme Visual Basic Talk > > > Using Loops or Arrays


Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2014, 04:01 PM
Marred Marred is offline
Newcomer
 
Join Date: May 2014
Posts: 4
Default Using Loops or Arrays


So I'm rather new to Visual Basic. Been using it for a couple months now, however I'm not too familiar with how to use looping and arrays. My game that I'm currently making uses a lot of timers. I'm not done the game but I think there's going to be 40+ timers.

My main question is, how can I implement this coding:

http://pastebin.com/iYcS3p0s

into a more efficient way? I know I can try looping but I'm not sure how to use variable names as part of the loop counter.

And with arrays, I'm just not too familiar with them at all.

Thanks
Reply With Quote
  #2  
Old 07-14-2014, 05:44 AM
PlausiblyDamp's Avatar
PlausiblyDampUsing Loops or Arrays PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,055
Default

Control Arrays in .NET should give you an idea of how to use arrays when working with controls.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 07-20-2014, 10:02 PM
Marred Marred is offline
Newcomer
 
Join Date: May 2014
Posts: 4
Default

Thanks for the reply! Much appreciated for showing me, but I have just one more question. Most of my coding is being blocked and put into individual timers. The thing is, I have twenty plus timers. Is this okay? Almost all of them are running every ms and I'm wondering if there's an alternative to this.

I looked up multi-threading but it seems too complex and unnecessary for a simple game like the one I want to make.
Reply With Quote
  #4  
Old 07-20-2014, 10:04 PM
Marred Marred is offline
Newcomer
 
Join Date: May 2014
Posts: 4
Default

Thanks for the reply! Much appreciated for showing me, but I have just one more question. Most of my coding is being blocked and put into individual timers. The thing is, I have twenty plus timers. Is this okay? Almost all of them are running every ms and I'm wondering if there's an alternative to this.

I looked up multi-threading but it seems too complex and unnecessary for a simple game like the one I want to make.

Edit: ...what >.> I clicked to submit the reply then it led me to the go advanced editting, so I thought the post didn't go through so I clicked it again and it seemed that I replied twice -.-
Reply With Quote
  #5  
Old 07-21-2014, 06:19 AM
PlausiblyDamp's Avatar
PlausiblyDampUsing Loops or Arrays PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,055
Default

Could you not just use a single timer and do multiple things every time it fires? 40+ timers sounds rather a lot.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #6  
Old 07-21-2014, 08:38 AM
Marred Marred is offline
Newcomer
 
Join Date: May 2014
Posts: 4
Default

Oh, well yes actually I can do that. The problem is that I want to be able to, in other block of code, tell which timer that's looping a certain action to stop. Another thing is that for example if I have two enemies, if I have them randomly moving I don't want the interval for both of them to be the same so both of them change directions at the exact same time, which would seem a bit odd.

What I have set up for that case is one timer that RND's an interval for the enemy timer. The next timer then waits for it's wait to finish then it turns on a third timer, the second one turns off, then the third one changes direction of the enemy and moves it.

There are a number situations, but yeah there are others where I could jumble into just one timer, I can definitely do that. I also just thought it would have been a bit easier the way I currently have my game set up since it's easy to find the code that I want rather than a lot of different things that would be hard to put under one name.
Reply With Quote
  #7  
Old 07-22-2014, 03:36 AM
PlausiblyDamp's Avatar
PlausiblyDampUsing Loops or Arrays PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,055
Default

Quote:
but yeah there are others where I could jumble into just one timer, I can definitely do that. I also just thought it would have been a bit easier the way I currently have my game set up since it's easy to find the code that I want rather than a lot of different things that would be hard to put under one name.
This all ultimately comes down to code organisation, having individual functions for individual tasks that may be called from a single timer will make things cleaner, using classes to group related data and functionality together will also be a big help.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays Using Loops or Arrays
Using Loops or Arrays
Using Loops or Arrays
 
Using Loops or Arrays
Using Loops or Arrays
 
-->