Drawing Grid - Moving Snake To Square?

Apr 7, 2009

I am setting up a snake game, I just like to know a few things. Do I require a GRID? and the grid needs to be the same size as the square obviously but how do you go about moving the snake to the square. I mean why do I even require a grid? Why cant I move the snake by its own size. Just need some clarification of the steps I should take to make my snake game. I would like to do this from scratch.

View 2 Replies


ADVERTISEMENT

Mouse Clicks A Square In Grid That It Changes Color?

Aug 12, 2009

I know how to draw a grid with dots,system.Windows.Forms.ControlPaint.DrawGrid(e.Graphics, e.ClipRectangle, New Size(NewMap.MapX, NewMap.MapY), Color. Blue)But what i dont know how to do is make a grid with lines do i do like a loop and put squares up untell they = a given amount.Also when that is done how do i make it so if the mouse clicks a square in the grid, that it changes color? I got a sorta grid working it makes a good grid for the first like 5 squares then it makes more and they increase in size. [code]

View 17 Replies

Graphics Drawing And Moving Controls?

Oct 21, 2010

I know this is probably not going to be simple, I tried searching around, but couldn't find anything. I am using some code to 'draw' text in a custom format to a panel with a custom bitmapped region (custom shape).Here is the code that writes the text inside a specified area:

g = LeftControlPanelV2.Panel1.CreateGraphics
Using fnt As New Font(New FontFamily("Arial"), 9, FontStyle.Regular, GraphicsUnit.Point)
Dim sf As StringFormat = StringFormat.GenericDefault
sf.Trimming = StringTrimming.EllipsisWord

[code]....

Obviously the text is not really located on the panel, but looks like it as it's drawn on top of the panel. So, when the panel or form that the panel is attached to moves, I lose the text. I though I could just call back to writing the text when the panel/form arrives at the correct place, while clunky, it works to a degree. I was hoping there was a better way of doing this, so that the text doesn't disappear when moving controls and I don't have to make repeated calls to the same drawing text over and over and over...

Edit: Should probably add that there will be 5 different panels each with their own custom drawn text, and all 5 need to move at the same time...

View 2 Replies

VS 2008 Drawing A Grid?

Apr 23, 2009

I am having a bit of trouble drawing a grid with GDI+ and VB.net 2008. The grid is designed as one point perspective. The horizontal lines are not correctly positioned, and the form is taking a long time to draw. Could anyone suggest a faster, and mainly more accurite method?

Here is my code currently:

Public Class Form1
Const VanishPoint = -200
Dim g As Graphics = Graphics.FromImage(New Bitmap(Me.Width, Me.Height))

[Code]...

View 2 Replies

VS 2008 Round E.Location To Nearest Grid Square Location?

Nov 9, 2009

I was using this old method of creating a bunch of rectangles when I need to get the location of a certain point within a grid so I could draw images on the grid. The thing is, I don't want to use rectangles, I want to be able to just round the location as if I were using rectangles. I need it to be able to round the point (66,70) to (50,50) so if you can imagine a grid and the mouse position being within that square in the grid, I need to get the location of the upper left corner of that square.

View 5 Replies

Moving To Current Record In Data Grid?

Mar 12, 2010

I m workin on vb.net ado.net oledb, I have also added datagrid Control to my form

for retriving database from .Mdb file i used following code

Code:
'decleared Name Space
Imports System.Data.OleDb

[Code]....

or when i click any record in datagrid, then the current record of dataset also should move to clicked record of datagrid, so that i also may see datagrid's clicked record in textboxes

in short i want to use default feature of vb6's ado control, when we bind datagrid with ado control, it worked autometically, both data grid and adodc wer connected each other at a time, so that moving next record also apears in datagrid.

View 5 Replies

VS 2008 - Drawing A Rectangle Snapped To A Grid By Getting Start Point

Dec 27, 2009

I'm drawing a rectangle snapped to a grid by getting the start point(Mouse down e.location) and the end point(mouseup(e.location). The coding I'm having trouble with is having the program determine which way to draw the rectangle(where the location should be, and the height and width.) Now, this would be extremely simple if the user started their rectangle from the top left corner and ended it in the bottom right every time. But you need to be able to drag from all angles. So does anyone have some code lying around that I could look at so I could actually get my rectangles drawn right?

View 5 Replies

Game Of Snake & Ladder. Vb?

Feb 17, 2009

[URL].. to helping me in this game >>> plzi want some changes in that game >>* set the game as full screen .. not only form ..* change automatic moving to maneul...after throw a nurd, and change the players command colour for from defult"gray" to red and blue ...ect.* add textbox or lable or masgbox to add Questions "i've it"... as hiddenwhen nurd stop set as shown and the Questions change every time with nurd

View 2 Replies

Make A Snake Move?

Apr 2, 2009

Okay i only need to know how in the world do you make the snake move towards one direction at the beginning?

View 7 Replies

Project For School (snake Game)

Dec 6, 2010

Iam doing a project for school (snake game) Ok here is the code:

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

Snake.image is the head of snake and snake2.image to snake27.image are the rest(body...) So i want create a code that (if snake intersect snake2 to snake27 parts) then timer1.stop I have tryed with:

CODE:

But it doesnt work..

View 6 Replies

.NET Snake Game Freeze When Hold A Key Down?

Dec 24, 2011

I'm trying to make the classic Snake game in VB.NET, but if I hold a key (any key) during the game, after a few seconds the game freezes until I release the key. I've tried lots to fix this, but nothing works, maybe because I don't understand the problem.I'm assuming that when I hold down a key, the Form1_KeyDown function gets called, and when, after a few seconds, the key goes into "I'm being held down" mode, that function is constantly called, so the timers don't get a chance to update. But like I said, I'm probably wrong.

I've been struggling with this for a while. I think this is all the necessary code, please let me know if it isn't.

[Code]...

View 3 Replies

Process Of Making A Snake Game Using .NET?

Jul 23, 2010

I am currently in the process of making a snake game using VB.NET... I was just wanting to gather ideas on how to do the body of the snake..Currently I have a class called SnakeBody which contains the following code:

[Code]...

I guess what I am asking is if Dim body As PictureBox a logical thing to put in my class. As in, I am not sure if that is the correct thing to do? To create the actual body of the snake I will have an array of these SnakeBody objects. If `'Dim body As PictureBox is valid How do I reproduce the same picturebox everytime my snake eats something?

View 2 Replies

Red Block Making Not Working-Snake?

Mar 11, 2009

I am currently working on a snake game. I am trying to make a red block appear every time you eat food a red block appears. If you hit the red block, you die. For some reason, food works, but the red blocks never appear

View 6 Replies

Snake Game Food-Making?

Mar 3, 2009

I just started a snake game. This is what I have so far:

View 2 Replies

Snake Game Freeze When Hold A Key Down?

Apr 8, 2012

I'm trying to make the classic Snake game in VB.NET, but if I hold a key (any key) during the game, after a few seconds the game freezes until I release the key. I've tried lots to fix this, but nothing works, maybe because I don't understand the problem.'m assuming that when I hold down a key, the Form1_KeyDown function gets called, and when, after a few seconds, the key goes into "I'm being held down" mode, that function is constantly called, so the timers don't get a chance to update.

View 10 Replies

VB Snake Game Troubles With Array And Growing?

May 26, 2010

im making a game for my assignment of snake. Vb10 Im coding 90% by teaching myself. Was just wondering if anyone has any idea how to help me. Im stuck with the array for making new pictureboxes and moving them to extend the snake here i some of the code.

Private
SnakeHead.Left = SnakeHead.Left + xDifference
SnakeHead.Top = SnakeHead.Top + yDifference
If SnakeBody(1).Left <> SnakeHead.Left And
SnakeBody(1).Top <> SnakeHead.Top Then

[Code]...

View 13 Replies

VS 2010 Snake Length Wont Increase?

Aug 15, 2011

I have a problem with snake game. I never tried to make a game with VB, but now i tried to make snake from this tutorial:So i added food to this snake game, and when i taking food, it increases score, but length cannot be increased and i don't know why. This code is in timer to check if snake head is on the food:

If p(m).X = food.Location.X And p(m).Y = food.Location.Y Then
score += 25
food.Visible = False

[code]....

View 9 Replies

Drawing Pixels With Me.creategraphics In System.drawing (yay)?

Jun 3, 2012

draw individual pixels, without resorting to drawing a line and setting it's length to 1. Is there an actual ability to draw a pixel that is just 1 pixel big?

View 2 Replies

Game - Make The Snake Grow When It Hits Food

May 30, 2010

I am simply trying to make the snake grow when it hits food, however, I am at a stand still.

[Code]...

View 2 Replies

Exit Grid With Ctrl-TAB When Grid Is On A Tabpage (onkeydown Works When Grid Not On Tabpage)?

Jun 2, 2010

winforms .net 3.5 Ultrawingrid 9.2 In my subclass of Ultrawingrid.Ultragrid :

[Code]...

This works fine. But when the grid is dropped on a TabControl tabpage, the ctrl-tab looks very different to the sub above. e.keycode is seen as controlkey {17} I realize that by default cntrl-Tab moves between tabpages. I need to override this behavior. My thought is I probably need a subclass of the tabControl which will pass the keycombo through just as the form does but I confess to being clueless as to how to accomplish that. I tried to override the onkeydown of a tabcontrol subclass and just issuing a return and not and base call to onkeydown if the ctrl-tab combo was pressed but it seemed to see the e.keycode as controlkey as well.

[Code]...

View 1 Replies

VS 2008 Creating A Snake Game - PictureBox2 Touches PictureBox15?

May 21, 2010

we were asked to create a game.Me and my friend decided to go ahead and make the game 'Snake' (I think you all know this one)Since we never had any teaching on how to do it we looked already made games and used the same code (we found this one on a Youtube tutorial so I think it was alright to copy it).We picked it because it seemed pretty easy and we can tell what each thing does in the code.I also like fooling around so I changed all he values and stuff so I understood better what was going on.The game goes great but sometimes when the snakehead touches the food it doesn't 'eat' it and I don't know why :This is the part of the code that takes care of eating the food.(PictureBox2 is the snakehead, PictureBox15 is the food)

[code]...

I just don't know why does happens. The PictureBox2 touches PictureBox15 but nothing of what I typed above happens.

View 6 Replies

Making Moving Percentages Into A Moving Graph?

Oct 5, 2008

I have this:

Private m_PerformanceCounter As New _
System.Diagnostics.PerformanceCounter( _
"Processor", "% Processor Time", "_Total")

[code]......

View 4 Replies

Game Programming :: Make Snake In VB For Major Year 12 Project In Australia?

Apr 3, 2008

im trying to make snake in visual basic.net for my major year 12 project in Australia and i cant get it to work?

View 5 Replies

Drawing On Picturebox Vs Drawing On Form?

Feb 18, 2012

I need some code to draw a resizable, draggable rectangular cursor (or selection box) on a picturebox. I found some excellent code (albeit rather old) that does just that, but on a form rather than a picturebox. I have tried converting the code - basically moving things to the picturebox events (Paint, MouseDown, MouseMove etc). It nearly works but leaves a trail behind it when you move or resize the cursor. In other words, the selection rectangle is not being erased before being drawn in the new position.

Is there some fundamental difference between drawing graphics on a form and drawing on a picturebox that would cause this behaviour? Something like, when you invalidate a form and cause a redraw it erases what you did last? If not, then I just need to dig a bit further and work out how the cursor is being erased from the previous position.

Here's the original code that works fine on a form:

Private DragRect As New RectangleF(20, 20, 100, 80)
Private Adornments(7) As RectangleF
Private MouseInRect As Boolean = False

[Code]....

View 1 Replies

Click Button To Insert Drawing, Click Drawing To Get Option To Delete - VB Versus Access

Jun 21, 2010

Say I have 3 Buttons, labelled: Unit 1, Unit 2 and Unit 3. When I click on any button I want a drawing of that unit to appear on screen at a pre-specified starting point. Thereafter when I press any other one of the buttons the unit drawings appear alongside each other in a line. So I could end up with:

[Code]...

View 4 Replies

Error: Operator '=' Is Not Defined For Types 'System.Drawing.Image' And 'System.Drawing.Bitmap'

Aug 17, 2009

With this line...

If PictureBox1.Image = My.Resources._2star Then

I get this error: Operator '=' is not defined for types 'System.Drawing.Image' and 'System.Drawing.Bitmap'.Is there another way to say = with images?

View 8 Replies

Convert An Object Form System.Drawing.Graphics To System.Drawing.Image?

May 23, 2009

Is it possible to convert an object form System.Drawing.Graphics to System.Drawing.Image?

View 4 Replies

Error Value Of Type System.Drawing.Image Cannot Be Converted To System.Drawing.Icon

Jan 21, 2010

Here is my favicon code

Dim oURL As Uri = New Uri(e.Uri.AbsoluteUri)
Dim favicon As Image
If oURL.HostNameType = UriHostNameType.Dns Then

[code]....

The error is Value of type System.Drawing.Image cannot be converted to System.Drawing.Icon Is it even possible to make the favicon be the icon of the form?

View 4 Replies

MVCContrib Grid Overriding RowStart And RowEnd - The Row Start And End Are Rendered Above The Entire Grid

Jan 26, 2011

i'm using the MVCContrib grid trying to override the start of a row and the end of a row. It's not working as advertised. This is an extract from my MVC2.0 view.

<div id="chargestable">
<br />
<% With Html.Grid(Model.InvoiceListingInformation)
.Columns(Function(column)

[code]....

The stuff i put in the begin row and end row functions is being rendered above the grid entirely.(PS i can't just use the attributes as i need to wrap the row in another html element)

View 1 Replies

Showmodaldialog - Display The Text Entered In The Grid - Access The Grid In Child Window

Mar 11, 2010

i have a prob that i have a gridview on the parent window. when i open a child window using showmodaldialog, i enter some data in the textboxes. now when i close my child window i want to display the text entered by me in the grid. i want to know how can i access the grid in child window

View 1 Replies







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