0% found this document useful (0 votes)
18 views

Using Using Using Using Using Using Namespace Class New Int New Int Public Void

The document contains code for a ClassCiudad class in C# that controls the movement and behavior of vehicles in a simulated city environment. The Marcha method moves a car picturebox object through different points on the form to simulate driving along streets and turning corners. The SEMAFORO1 method controls a traffic light simulation by changing the visible state of picturebox objects representing the light colors and changing timers at different steps of the light cycle.

Uploaded by

ROSALY BALBUENA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Using Using Using Using Using Using Namespace Class New Int New Int Public Void

The document contains code for a ClassCiudad class in C# that controls the movement and behavior of vehicles in a simulated city environment. The Marcha method moves a car picturebox object through different points on the form to simulate driving along streets and turning corners. The SEMAFORO1 method controls a traffic light simulation by changing the visible state of picturebox objects representing the light colors and changing timers at different steps of the light cycle.

Uploaded by

ROSALY BALBUENA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace PrjCiudad
{
class ClassCiudad
{
Random r = new Random();
int random = 0;
Point pos = new Point();
int caso = 0;
public void Random()
{
random = r.Next(1 , 2);
}
public void Marcha(PictureBox carro,Timer tiempo)
{// marcha de lado

if (carro.Location.X == 52 && carro.Location.Y <= 620 )


{

Point pos = new Point();


pos.X = carro.Location.X;
pos.Y = carro.Location.Y - 2;
carro.Location = pos;
}

// hacia arriba
else if (carro.Location.X >= 94 && carro.Location.Y == 366 ||
carro.Location.X >= 89 && carro.Location.Y == 183
|| carro.Location.X >= 99 && carro.Location.Y == 29)
{

pos.X = carro.Location.X + 2;
pos.Y = carro.Location.Y;
carro.Location = pos;

}
//Calle Curva2
if (carro.Location.X == 286 && carro.Location.Y == 414)
{
pos.X = carro.Location.X + 10;
pos.Y = carro.Location.Y+3;
carro.Location = pos;
carro.Location = new Point(296, 417);
carro.Size = new Size(40, 50);
carro.Image = Image.FromFile(@"F:\imgenes Vehiculos\oie_transparent
(9).PNG");
tiempo.Interval = 500;
}
else if (carro.Location.X == 296 && carro.Location.Y == 417)
{
carro.Location = new Point(300, 427);
tiempo.Interval = 500;
}
else if (carro.Location.X == 300 && carro.Location.Y == 427)
{
carro.Location = new Point(303, 443);
tiempo.Interval = 500;
}
else if (carro.Location.X == 303 && carro.Location.Y == 443)
{
carro.Location = new Point(309, 450);
tiempo.Interval = 500;
}
else if (carro.Location.X == 309 && carro.Location.Y == 450)
{
carro.Location = new Point(325, 476);
tiempo.Interval = 500;
}
else if (carro.Location.X == 325 && carro.Location.Y == 476)
{
carro.Location = new Point(331, 489);
tiempo.Interval = 500;
}
else if (carro.Location.X == 331 && carro.Location.Y == 489)
{
carro.Location = new Point(344, 510);
tiempo.Interval = 500;
}
else if (carro.Location.X == 344 && carro.Location.Y == 510)
{
carro.Location = new Point(356, 523);
tiempo.Interval = 500;

}
else if (carro.Location.X == 356 && carro.Location.Y == 523)
{
carro.Location = new Point(370, 547);
tiempo.Interval = 500;
}
else if (carro.Location.X == 370 && carro.Location.Y == 547)
{
carro.Location = new Point(383, 566);
tiempo.Interval = 500;
}
else if (carro.Location.X == 383 && carro.Location.Y == 566)
{
carro.Location = new Point(388, 380);
tiempo.Interval = 500;
}
else if (carro.Location.X == 388 && carro.Location.Y == 380)
{
carro.Location = new Point(391, 593); tiempo.Interval = 500;
}
else if (carro.Location.X == 391 && carro.Location.Y == 593)
{
carro.Location = new Point(404, 614); tiempo.Interval = 500;
}
else if (carro.Location.X == 404 && carro.Location.Y ==614)
{
carro.Location = new Point(410, 622); tiempo.Interval = 500;
}

//Esquinas
if (carro.Location.X >= 52 && carro.Location.Y == 412)
{
Random();

if (random == 1)
{

carro.Location = new Point(94, 366);


carro.Size = new Size(55, 26);
carro.Image = Image.FromFile(@"F:\imgenes
Vehiculos\horizontal.JPG");
}

}
//
if (carro.Location.X == 52 && carro.Location.Y == 219)
{
Random();
if (random == 1)
{
carro.Location = new Point(89, 183);
carro.Size = new Size(55, 26);
carro.Image = Image.FromFile(@"F:\imgenes
Vehiculos\horizontal.JPG");
}
}
//
if (carro.Location.X == 52 && carro.Location.Y == 70)
{
carro.Location = new Point(99, 29);
carro.Size = new Size(55, 25);
carro.Image = Image.FromFile(@"F:\imgenes
Vehiculos\horizontal.JPG");
}

//
if (carro.Location.X == 206 && carro.Location.Y == 366)
{
Random();
if (random == 1)
{
carro.Location = new Point(286, 414);
carro.Size = new Size(30, 50);
carro.Image = Image.FromFile(@"F:\imgenes
Vehiculos\oie_transparent - copia.PNG");
}
}
}

public void SEMAFORO1(PictureBox verde, PictureBox amarillo, PictureBox


rojo, PictureBox apagado1,
PictureBox apagado2, PictureBox apagado3, Timer tiempo)
{
switch (caso)
{
case 0:
apagado3.Visible = false;
apagado1.Visible = true;
verde.Visible = true;
tiempo.Interval = 5000;
caso =1;
break;
case 1:
apagado3.Visible = true;

apagado2.Visible = false;
amarillo.Visible = true;
tiempo.Interval = 2000;
caso = 2;
break;
case 2 :
apagado1.Visible = false;
apagado2.Visible = true;
amarillo.Visible = false;

rojo.Visible = true;
tiempo.Interval = 5000;
caso = 0;
break;
}
}

}
}

You might also like