VS 2010 : Space Invaders Alien Loops/arrays?

Oct 2, 2011

Been given an assignment to create a space invaders game. Although there's a long way around, is there a way to make my code smarter.Here's the section to make a row of invaders so far:

Public Class Form1
'number of invaders in a row (horizontal)
Dim numberofinvaders As Integer = 11
'set of invaders (vertical)

[code]....

So what I want to do more precisely is have the value of setofinvaders to change how many rows of invaders vertically in a loop.

View 13 Replies


ADVERTISEMENT

VS 2010 Space Invaders Queries?

Oct 15, 2011

I've got everything working except this one problem which I can't seem to get my head around.I've made a function that returns a random number between 1 and 11 (how many invaders there are on a row).I've managed to get this to work, however the invaders will keep firing even if they are visible, so I made a do until loop which says to keep running the random number until it finds an invader which is visible... The problem is that if the whole row of invaders aren't visible, it will get stuck in the loop.

View 13 Replies

Creating A Space Invaders Game That Has A Group Of "invaders" Moving Side To Side?

Dec 2, 2009

Im creating a space invaders game that has a group of "invaders" moving side to side and when i shoot one it gets destroyed, my invaders are in an array. So in order for the invaders to keep moving right until they get to the edge, i made a function that detects which invader is right most. But this was crudly done as I wa trying to make the opposite of my left most function which works. So my rightmost function dosent work

[Code]...

View 19 Replies

Creating Projectile - Make A Space Invaders Rip Off

Apr 10, 2009

I'm trying to make a space invaders rip off, and I'm currently stuck on how to make the missile fire from the center of the player's ship. I have the missiles all in a control array, and they move up the screen fine, they just dont start at the x point of the ship, they start on the left margin.

Dim Line As Integer

If Missile(0).Location.Y < 391 Then

Missile(0).Location = New System.Drawing.Point(Line, Missile(0).Location.Y - 5)

[CODE]...

View 8 Replies

Simple 2D 'Space Invaders' Clone In Silverlight

Mar 17, 2011

I want to make a simple 2d game in Silverlight, but it seems like things have changed since the last time I tried to make a game using mode 13h graphics. Can someone give me a run-down of how you'd go about it.I just mean at a high-level, focusing on the silverlight-specific aspects; not general game design.A fictional example might be:'The main game loop shouldn't be a loop, use a DispatchTimer instead. Use a Canvas as the main drawing object; but realize that we don't bother drawing individual pixels - all of your in-game objects should be represented by controls. Be sure to set the 'UseHardwareFlag' to true'.

View 1 Replies

Game Programming :: Space Invaders .NET Compact Framework?

Oct 2, 2008

i'm not very familiar with GDI+, but i managed to create some basic functions of Space Invaders game i try to develop in Compact Framework. I have problems drawing the images (Spaceship, bullets, enemies). The screen is flashing a lot. I use a buffer bitmap in which i draw images to the new positions, and i have 1 line of code that just draws the buffer to screen

[Code]...

i use me.Invalidate inside a timer so every 50msec the game redraw the screen with new positions. Why the buffering does not work?? It can't be the emulator that i preview the program, it is flashing A LOT. Is there any similar code / project that could help me? i'm tring to find a similar project for COMPACT FRAMEWORK but i only find C++ .net examples. i need VB .NET COMPACT FRAMEWORK examples

View 2 Replies

VS 2010 - Arrays And Do Loops With Rows And Columns

Feb 28, 2011

So I am writing a program that uses ArrayA(10) and ArrayB(10) and uses Do loops to output the sum of ArrayA(1) + ArrayB(1) in one column then the difference in the next column, then the product in the next column, then the quotient in column 4 of a Matrix(10, 4) in a listbox. And continues doing this until there are 10 rows of 4 columns. I was wondering for tips on how I can get this done.

View 6 Replies

VS 02 / 03 Checking ".Left" Of Whole Object [Space Invaders]

May 20, 2009

What I mean by "Checking ".left" of whole object" is making something happen if, for instance, a label were to hit an object. Instead of it needing to hit at the objects exact left, it could hit anywhere on the object. Bit confusing...I know...here is an example...

[Code]...

View 5 Replies

How To Reference Arrays Via Loops

May 21, 2009

I have 5 arrays named array1 array2 array3 array4 array5. Each array has 5 elements. I want to access each element in each loop via a for next loop the pseudo code would be something like this.

for i = 1 to 5 / this loop calls the individual arrays
for j = 0 to 4/ this loop calls the elements in each array
array (i,j) /do some action on the element here
next j
next i

But as it stands, there is no array called simply array, and I can't figure out how to append the i counter to the word array and thus achieve what I want.
The alternative is to have 5 separate loops, one for each array but I feel sure there must be a better way.

View 5 Replies

Index Was Out Of Bounds - For Loops And Arrays

Nov 23, 2009

I'm trying to create two arrays filled with a set of strings from two tables in a database and then compare them. For example:
array1[0]="1101" and
array2[0]="0110"

If both respective characters equals 1 then perform an action. But when I run this code I receive the error: Index was outside the bounds of the array. System.IndexOutOfRangeException.

For some reason I believe the problem area is with the following two statements:
comparestringa = userintarray(x) and
comparestringb = eventintarray(x)

When I comment them out, the error doesn't show.
myconnect = New SqlConnection("xxxx")
Dim Table1 As New SqlCommand("SELECT * FROM Table1", myconnect)
Dim Table2 As New SqlCommand("SELECT * FROM Table2", myconnect)
Dim array1 As New ArrayList
Dim array2 As New ArrayList
Table1.Connection.Open()
[Code] .....

View 4 Replies

Loops And Arrays - After The Loop Is Completed - Pull A Value From The Array And Display It?

Apr 15, 2012

i have a array set up, and i need the array to be global, but i can only get vb to accept it in a button, in addition, after the loop is completed, i am trying to pull a value from the array and display it but am getting an error.the code is as follows:

Public Class Form1
Friend staten As String
Friend statea As String[code].....

View 7 Replies

VS 2008 Arrays And Loops - Computing Average Monthly Rainfall

Dec 2, 2010

I need to create an console application that computes the average monthly rainfall, number of months with above average rainfall, and the number of months with below average rainfall, given the rainfall amounts for each month in a particular year. The program must read in and store in an array the monthly rainfall amounts entered by the user one by one.

So far this is what I have got
Const intMonths As Integer = 11 'Constant Month variable
Dim sngRainfall(intMonths) As Single 'Rain for the month
Dim intCount As Integer ' Loop Counter
Dim sngTotalRainfall, sngAvgRainfall As Single 'Total and Average Rainfall
[Code] .....

How to set this up properly and I am having a real hard time figuring out how to make the data go from this loop to another and add the data to the total.

View 15 Replies

Make An Invaders-like Game With VB 2010?

Jan 10, 2010

i am currently trying to make an invaders-like game with visual basic 2010.I've managed to make one alien (picturebox16) dissapear when the coordinates of the arrow (picturebox1) kinda matches the coordinates of the 16th alien, however, the second alien(above it) doesnt dissapear(picturebox4)?

View 2 Replies

Do Arrays Take Up Space Even Without Values In Them In .net

Sep 28, 2011

I have a program in VB.net that uses a 3D array:

Private gridList(10, 900, 900) As GridElement

Now, I just used a Memory Profiler on it (because my application is having some major leak issues or something) and apparently, this array (containing at the moment of testing 0-30 elements at one time) is using 94% of the memory currently in use by my application. Even when it is empty it takes up huge amounts of memory.

My only assumption is that even empty arrays take up space! This puts a major blow into my plans!

My Question:

Is there any alternative to this that allows me to still have the same abilities to map i.g. I've been using it like this:

Dim cGE as GridElement = gridList(3, 5, 7)

but doesn't hog up so much memory for things that aren't using memory?

View 1 Replies

File I/O And Registry :: Opening A Text File Into Multiple Text Boxes Using Loops And Arrays

May 20, 2009

So I'm in the final stages of finishing a program I've been working on for nearly a year now, and this is basically my final hurdle. The Save dialogue is working beautifully, with 'flags' in order to switch it over from the regular input into text boxes to the Listbox input protocol.

However, I'm having a *** of a time getting it to take lines from the text file and put them in the proper text box. Here is an example file:

Quote:

SHOWNAME
CALLNAME
BREED

[Code]....

So with the sample file I provided above, in the textbox named callNameText would appear "SHOWNAME", and so on and so forth. With this build, I get a NullReferenceException on the "Me.Controls(strboxNames(i)).Text() = strAllText(ati)" line.

View 1 Replies

Monthly Payment Calculation, For Loops To Do While Loops?

Oct 8, 2011

the purpose of the program is to display the monthly payments on the loan.My homework is to use do while loops instead of for loop.Here is the code for the for loop.

Option Explicit On
Option Strict On
Option Infer Off

[code].....

Now I'm having some trouble displaying the output using the do while loop, and I'm pretty sure it's a loop problem on my code. However, I cannot seemed to find out what's wrong. I looked at the examples of do while loop in my textbook, but I couldn't find anything useful to my problems of my program.This is the output for the do while loop.

Here's the do while loop code

Option Explicit On
Option Strict On
Option Infer Off

[code].....

View 3 Replies

Get A Certain Text Inside A Textbox To Equal That Text Space To Space Or Null To Space?

Sep 25, 2011

How would i get a certain text inside a textbox to equal that text space to space or null to space?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Textbox1.Text.StartsWith(Textbox2.Text + " ") And Not String.IsNullOrEmpty(Textbox2.Text) Then
Textbox1.Text = Textbox1.Text.Remove(0, Textbox2.TextLength)
Textbox3.AppendText("a")
End If

Btw: after i finish this step my project will be finished!

View 4 Replies

Contain Functions(They All Have For Loops) Don't Work In For Loops?

Mar 6, 2011

When I use a For loop in a For loop the Contains Statement dosen't work! Even my custom one! I even tested mine and it works 100% And neither that or the String.Contains function work inside of For Loops And, I know both of them use loops to search through a string.

My function(It will atleast search once):

Function RealContains(ByVal load As String, ByVal needle As String) As Boolean
load = load.ToLower

[CODE].....................

View 10 Replies

VS 2010 - Textbox Handling For XML While Loops

Oct 18, 2011

I have a sub which creates an XML file but the thing is, all the parameters are 'hardcoded', so I decided to give some inputs so each data in each node is customizable. Now, I would like a loop to read the text in textbox1 and assign that to variable one, do the same for textbox2, write the node, loop again (using the same variable) and assign that variable a value in textbox3 and write the node.

I can while loop to write nodes, but only for fixed data or data with 500000 variables for each loop. Is there any way to do this such that on each loop it dynamically sources the variables data from the 'next text box'. i.e. One first loop uses textbox1, second loop it knows it has used textbox1 .'. it uses textbox2 etc... Is there a way to do the same thing but write back to text boxes in an order, knowing what was previously written.

View 1 Replies

VS 2010 : XML Child Nodes 'loops'?

Jun 1, 2011

I have a bunch of XML's that need to be put into an SQL database. One XML represents all orders for a certain department of a store. The problem (for me) is that in one XML there can be (and are) multiple orders (called distributions in my case.) The XML looks as follows (truncated):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<order><process_id>322867</process_id>
<key1>RET</key1>
<key2>40_134985</key2>

[code]....

So in this example I have two 'distributions'. Now I can get all data out of the XML fine, which I do like this:

get xml data
awsFeed = XDocument.Load(fileName)
Dim orders = From order In awsFeed...<order> _

[code]....

However, in this case my SQL input would have to result in 2 entries, because there are 2 orders. Both entries would have the same data, except for different entries. I know how to post to SQL, that's not the problem. My real problem is, how do I 'loop' it through the XML. I think i'm looking for something like:For each 'distribution' in orders -> put into array.Or something like that. After that I could query the array and put it in the database.

View 5 Replies

VS 2010 Exiting Subs - For Loops

Apr 24, 2011

This code is supposed to check if an item already exists in a ListView, and if not, add it. But it still adds it even if it was already there. All variables are set and fully working. The addable string is in an array.

Private Sub btnCombine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCombine.Click
For Each comb As Array In combinables
If comb(0) = Selection1 Then

[CODE]...

View 5 Replies

VS 2010 Is LINQ Faster Than For-loops

Jul 4, 2010

I have an array of approximately 1000 classes. All of these classes must have one of their properties changed to the same value. I need this to be as optimized and fast as possible.

Would LINQ be faster than a for-loop? Any other ideas for faster execution?

View 11 Replies

VS 2010 Speeding Up For Next Loops With BackGroundWorker Usage?

Jan 19, 2012

I've wrote this code to accomplish what the image below looks like. This works fine for anything that is around 40x40 but if I try to do 100x100 it takes forever and sometimes errors out with a window handle error. Once it gets around the 40th column the labels start adding slower and slower. Is there anything I can do to make this more efficient? I added the backgroundworker routine in there to see if it would speed things up at all but it doesn't.

vb.net
Private Sub CreateGrid(ByVal rows As Integer, ByVal ranges As Integer)
If Me.InvokeRequired Then

[code]....

View 5 Replies

VS 2010 - Nested For Loops Seem To Only Trigger Once Instead Of The Number Of Times That Specified

Dec 7, 2011

I am trying to code something with nested for loop with the following format:

[CODE]...........

However when the program hits the last value of 'For loop 1', the nested for loops seem to only trigger once instead of the number of times that i specified.

Private Sub populatedgv1()
'setup temptable to store Server data
Dim m_table As New DataTable

[CODE]........................

View 7 Replies

VS 2010 - Space Will Disappear When Encrypt

Mar 24, 2012

i'm doing a bifid cipher project now my code is almost finish.. the problem is every i put a space the space will disappear when I encrypt take a look at my code

[Code]...

View 5 Replies

VS 2010 Trying To Auto-space Some Text

Oct 18, 2011

I'm just now starting to work on something that works 'like' an ide, where it will auto space my text as I type. I really JUST started and I'm not sure if I'm even doing it remotely like I should. anyways, what I'm doing is on TextChanged (eventually I'll just do it on newline but that can wait) it gets the contents of the text box, puts each line into a string array, trims the excess whitespace, see's if it has a keyword in it, and then adds some whitespace to it if it does.I know I'm doing something wrong with either my declarations or my error handling. Mostly because i'm not sure how to work with string arrays, can you help me with my syntax?[code]

View 2 Replies

VS 2010 Strings.Space VS String.Empty?

Jan 5, 2011

To create a string of space characters to a given length using the MS VB namespace I used,

Strings.Space(Length)But without the VB namesapce, how do I do the same thing, is it like this?...

String.Empty.PadLeft(Length, " "c)

View 2 Replies

VS 2010 Tell What The Size Of My Program Is And How Much Disk Space Is Needed To Install?

May 16, 2012

How can I tell what the size of my program is and how much disk space is needed to install. When I publish the program and install it on another machine it will show up in the control panel but does not show what size the program is?Also when I publish updates with it says something like installing 10mb. Is this an additional 10 mb everytime, I guess not, but can someone explain what it all means?

View 10 Replies

VS 2010 - Labels - Picture - Blank Item, Or Empty Space, A Control Has Failed To Draw Of Something

Nov 2, 2011

Everywhere in this picture you see a blank item, or empty space, a control has failed to draw of something. In this case they are all textboxes.

picture:

View 24 Replies

Visual Studio 2010 - .net Application Works With Files Dragged Onto The Exe But Crashes If There's A Space In The File's Path?

Jun 15, 2011

I'm developing an application in vb.net. You drag any type of file onto the exe, and a window pops up with some options for the file, then it saves the file to a different location, works some SQL magic, etc. It works great for the most part. The only issue I've found is that if the path of the file contains any spaces, the application will crash immediately with the error window:[URl]..I'm using: Private filename as String = Command$ This is located right inside my form's class declaration, not within a sub/function.Without this line, my program runs fine (although useless, without accessing the file).I've also tried (I think this was it, I don't have the code with me at the moment): Private filename as String = Environment.CommandLine So, in vb.net, is there a way to drag a file onto an exe and use that path name, even if there are spaces in the path name?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved