3 Replies - 616 Views - Last Post: 23 April 2016 - 01:40 PM Rate Topic: -----

#1 RoodSquirrel   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-April 16

Simple game code help

Posted 23 April 2016 - 01:12 PM

Hi,

Should be quite a simple one for anyone who has any experience.

Basically I am making a game very similar to space invaders in visual studio 2013. I a small box moving along the bottom of the screen and a few picture boxes slowly moving along the top bouncing from side to side.

The aim of this is for when the box at the bottom shoots a shot at the top picture box a sound is played depending on which box is hit. I have tried a few different ways of firing the shot/detecting when the shot hits the top boxes but most are laggy or depend on the picture boxes being spawned from code whereas I want mine to be premade in the gui.

I already have the code for bottom and top boxes moving but all I need is a way to fire the shot and a way of playing different sounds depending on which picture box is hit.

I was wondering if anyone could help me out with the code for this? I am quite new to coding so just playing around and really a little stuck up to now.

Any help is massively appreciated :)/>/> Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: Simple game code help

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14158
  • View blog
  • Posts: 56,748
  • Joined: 12-June 08

Re: Simple game code help

Posted 23 April 2016 - 01:24 PM

So you shouldn't use picture boxes. A lot of cruft and BS that comes with it.

Here's an example of a basic game engine using rectangles and bitmaps. Faster, more controlable.
http://www.dreaminco...-basics-part-1/

Playing sounds are pretty straight forward..
https://msdn.microso...v=vs.90%29.aspx
Was This Post Helpful? 2
  • +
  • -

#3 RoodSquirrel   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-April 16

Re: Simple game code help

Posted 23 April 2016 - 01:33 PM

Thank you will have a look at it now :)/>

This post has been edited by andrewsw: 23 April 2016 - 01:41 PM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1505
  • View blog
  • Posts: 3,808
  • Joined: 01-February 13

Re: Simple game code help

Posted 23 April 2016 - 01:40 PM

I agree with modi123_1 110%, you should not use PictureBoxes or any other control for the characters and objects in a Game like this. It will make your game animation slower and choppier with every PictureBox you "Spawn" and try moving. It will also use a lot more memory than it needs to. You should be drawing the characters and objects directly to the Form`s Graphics object. The Paint event is where you do that most often.

Using PictureBoxes for an animated game like this is a very common mistake that beginners make and do not figure out that the game is slow and choppy in the end because of all of the downfalls of using controls. Then they find out that they need to pretty much rewrite the whole game to do it the correct way.

Please read through the links that modi123_1 has given you. You can also check out the links below which explain some of this and have more examples you can check out.

Drawing and moving a game sprite image on a form
How to Create Video Games in VB.Net (Windows Forms)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1