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
  1. Home
  2. General Programming
  3. C#
  4. How to create a trafic program

How to create a trafic program

Scheduled Pinned Locked Moved C#
csharpjavatutorial
7 Posts 3 Posters 0 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.
  • H Offline
    H Offline
    Halawlaws
    wrote on last edited by
    #1

    Hi i was just wondoring if anyone knows how to create a trafic program with the 3 lights and cars going from left to right, right to left, up down and down up in c# i did it in java it is easy but how can we do it in c# thx /\|-||\/|/\|)

    L 1 Reply Last reply
    0
    • H Halawlaws

      Hi i was just wondoring if anyone knows how to create a trafic program with the 3 lights and cars going from left to right, right to left, up down and down up in c# i did it in java it is easy but how can we do it in c# thx /\|-||\/|/\|)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It also the same. You can take your java source code and a little bit changes then you can compile it using C#. The language is almost the same.

      H 1 Reply Last reply
      0
      • L Lost User

        It also the same. You can take your java source code and a little bit changes then you can compile it using C#. The language is almost the same.

        H Offline
        H Offline
        Halawlaws
        wrote on last edited by
        #3

        stancrm wrote:

        It also the same

        I know it is very similar but the thing is there are functions in java that i used that are not present in c# also i am not an expert in c# so for example i don't know how to represent the car as a moving object on the screen... thx /\|-||\/|/\|)

        J L 2 Replies Last reply
        0
        • H Halawlaws

          stancrm wrote:

          It also the same

          I know it is very similar but the thing is there are functions in java that i used that are not present in c# also i am not an expert in c# so for example i don't know how to represent the car as a moving object on the screen... thx /\|-||\/|/\|)

          J Offline
          J Offline
          Jun Du
          wrote on last edited by
          #4

          Halawlaws wrote:

          for example i don't know how to represent the car as a moving object on the screen...

          How did you represent a moving car on the screen in Java? Best, Jun

          H 1 Reply Last reply
          0
          • J Jun Du

            Halawlaws wrote:

            for example i don't know how to represent the car as a moving object on the screen...

            How did you represent a moving car on the screen in Java? Best, Jun

            H Offline
            H Offline
            Halawlaws
            wrote on last edited by
            #5

            Jun Du wrote:

            How did you represent a moving car on the screen in Java?

            With frames do i have frames in c#? thx /\|-||\/|/\|)

            J 1 Reply Last reply
            0
            • H Halawlaws

              Jun Du wrote:

              How did you represent a moving car on the screen in Java?

              With frames do i have frames in c#? thx /\|-||\/|/\|)

              J Offline
              J Offline
              Jun Du
              wrote on last edited by
              #6

              Windows Form in C# appears to be equivalent to Frame in Java. Best, Jun

              1 Reply Last reply
              0
              • H Halawlaws

                stancrm wrote:

                It also the same

                I know it is very similar but the thing is there are functions in java that i used that are not present in c# also i am not an expert in c# so for example i don't know how to represent the car as a moving object on the screen... thx /\|-||\/|/\|)

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                If you create a new Windows Form, then use the event Paint.

                private void Form1_Paint(object sender, PaintEventArgs e)
                {
                ...
                }

                Then write your code in this method. For example :

                private void Form1_Paint(object sender, PaintEventArgs e)
                {
                e.Graphics.DrawLine(new Pen(Brushes.Black, 1), 0, 0, 50, 50);
                }

                That code will draw a black line with width = 1, from (0,0) to (50,50)

                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