Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Studio 2015 & .NET 4.6
  4. snake game error, moving randomly.

snake game error, moving randomly.

Scheduled Pinned Locked Moved Visual Studio 2015 & .NET 4.6
helpgame-devtutorial
5 Posts 4 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    srinivasankrishnaa
    wrote on last edited by
    #1

    Guys i have designed a snake and its prey,the snake is moving but it is moving in all directions(reverse also)how to move this snake correctly to catch that prey and other prey to appear.I am trying this for past 11 days but i cant solve this.help me plzzzzz.......... i have designed it in vb guys...... i have added my code below...........

    P Z F 3 Replies Last reply
    0
    • S srinivasankrishnaa

      Guys i have designed a snake and its prey,the snake is moving but it is moving in all directions(reverse also)how to move this snake correctly to catch that prey and other prey to appear.I am trying this for past 11 days but i cant solve this.help me plzzzzz.......... i have designed it in vb guys...... i have added my code below...........

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      What exactly are you expecting from us? You have given us no code to work with. There's nothing here that we can use to give you the correct answer. Adding that you designed it in VB doesn't really add much does it? We can't guess what your code is just from that one statement.

      I was brought up to respect my elders. I don't respect many people nowadays.
      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      S 1 Reply Last reply
      0
      • P Pete OHanlon

        What exactly are you expecting from us? You have given us no code to work with. There's nothing here that we can use to give you the correct answer. Adding that you designed it in VB doesn't really add much does it? We can't guess what your code is just from that one statement.

        I was brought up to respect my elders. I don't respect many people nowadays.
        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        S Offline
        S Offline
        srinivasankrishnaa
        wrote on last edited by
        #3

        Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = Val(Label1.Text) +10 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick OvalShape1.Location = New Point(OvalShape1.Location.X, OvalShape1.Location.Y - 1) OvalShape3.Location = New Point(OvalShape3.Location.X, OvalShape3.Location.Y - 1) OvalShape4.Location = New Point(OvalShape4.Location.X, OvalShape4.Location.Y - 1) OvalShape5.Location = New Point(OvalShape5.Location.X, OvalShape5.Location.Y - 1) OvalShape6.Location = New Point(OvalShape6.Location.X, OvalShape6.Location.Y - 1) OvalShape7.Location = New Point(OvalShape7.Location.X, OvalShape7.Location.Y - 1) OvalShape8.Location = New Point(OvalShape8.Location.X, OvalShape8.Location.Y - 1) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() If OvalShape1.Location = OvalShape2.Location Then OvalShape2.Hide() End If Timer2.Stop() Timer3.Stop() Timer4.Stop() Timer5.Stop() Timer6.Stop() Timer7.Stop() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Timer1.Stop() Timer2.Stop() Timer3.Stop() Timer4.Stop() Timer5.Stop() Timer6.Stop() Timer7.Stop() End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick OvalShape1.Location = New Point(OvalShape1.Location.X, OvalShape1.Location.y + 1) OvalShape3.Location = New Point(OvalShape3.Location.X, OvalShape3.Location.y + 1) OvalShape4.Location = New Point(OvalShape4.Location.X, OvalShape4.Location.y + 1) OvalShape5.Location = New Point(OvalShape5.Location.X, OvalShape5.Location.y + 1) OvalShape6.Location = New Point(OvalShape6.Location.X, OvalShape6.Location.y + 1) OvalShape7.Location = New Point(OvalShape7.Location.X, OvalShape7.Location.y + 1) OvalShape8.Location = New Point(OvalShape8.Location.X, OvalShape8.Location.y + 1) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop()

        1 Reply Last reply
        0
        • S srinivasankrishnaa

          Guys i have designed a snake and its prey,the snake is moving but it is moving in all directions(reverse also)how to move this snake correctly to catch that prey and other prey to appear.I am trying this for past 11 days but i cant solve this.help me plzzzzz.......... i have designed it in vb guys...... i have added my code below...........

          Z Offline
          Z Offline
          ZurdoDev
          wrote on last edited by
          #4

          You should be able to just put some breakpoints in your code and see what is happening. It shouldn't be too difficult to fix, I would think.

          There are only 10 types of people in the world, those who understand binary and those who don't.

          1 Reply Last reply
          0
          • S srinivasankrishnaa

            Guys i have designed a snake and its prey,the snake is moving but it is moving in all directions(reverse also)how to move this snake correctly to catch that prey and other prey to appear.I am trying this for past 11 days but i cant solve this.help me plzzzzz.......... i have designed it in vb guys...... i have added my code below...........

            F Offline
            F Offline
            Filipe Moreira de Oliveira
            wrote on last edited by
            #5

            Dude, try out some simpler things first. Name your components accordingly to be able to identify what they are from their names. Then learn to work with debug and breakpoints, as ryanb31 has suggested. It's not my specialty to develop games (I do develop software and web applications professionally) but I've had to create a simple snake game in the beginning of this year, it was in C. I've tried coding first but that made me spend some hours with pen and paper later to fix all the logic. Games are far more complex than usual programs, because their logic involves positioning, collision, and in other cases that aren't yours - gravity, physics and stuff. It's much important to write down your logic with pen and paper before start coding. When your logic works in the paper, then you'll "translate" your notes into code. That works much better. :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups