C# Stuff | Off Topic | Forum

A A A

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

sp_Feed Topic RSS dirt
C# Stuff
Topic Rating: 0 (0 votes) 
May 25, 2015
5:54 pm
tedisvet
The Netherlands
Member
Members
Forum Posts: 135
Member Since:
February 19, 2015
sp_UserOfflineSmall Offline

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace PadGame
{

class Mailstate : GameObjectList
{
protected Button btnAdd, btnMail, btnTrash, btnArchive, backMenu, betalen, negeren; //Trash & Archive worden nog niet gebruikt, zie comment onder aan pagina.
SpriteGameObject background;
SpriteGameObject rekening1;
ImageList mailItems = new ImageList();
int mailX = 0;
int mailY = 100;
int mailCount = 0;
public bool newMail = false;
public Mailstate()
{

btnAdd = new Button("button", 1); //Rode knop links onderin
btnAdd.Position = new Vector2(PadMain.Screen.X-150, PadMain.Screen.Y-150);
this.Add(btnAdd);

betalen = new Button("spr_button_betalen", 1); //Rode knop links onderin
betalen.Position = new Vector2(850, 400);
this.Add(betalen);

negeren = new Button("spr_button_negeren", 1); //Rode knop links onderin
negeren.Position = new Vector2(850, 300);
this.Add(negeren);

/* btnBackToRoom = new Button("button", 2);
btnBackToRoom.Position = new Vector2(0, PadMain.Screen.Y - 50);
this.Add(btnBackToRoom);*/

background = new SpriteGameObject("playingView");
this.Add(background);

rekening1 = new SpriteGameObject("spr_rekening_1");
this.Add(rekening1);

backMenu = new Button("spr_bckMenuTemp");
backMenu.Position = new Vector2(0, PadMain.Screen.Y - 100);
this.Add(backMenu);

}

public override void HandleInput(InputHelper inputHelper)
{
List<GameObject> mailItem = new List<GameObject>(); //Maakt een lijst aan om nieuwe mails aan te kunnen maken.

if ( mailCount <= 16 && newMail == true)

{
for (int i = 0; i < 0; i++)
{
btnMail = new Button("sprMail", 1);
btnMail.Position = new Vector2(mailX, mailY);
mailCount++;
mailItem.Add(btnMail);
this.Add(btnMail);
mailX += 250; //Adds 250
Console.WriteLine("mailX: " + mailX);
if (mailX > PadMain.Screen.X) //When the position of the new mail instance is bigger than the screen width, Y drops down to a new row.
{
mailX = 0;
mailY += 350;
}
}
}

if (backMenu.Pressed)
{
Console.WriteLine("Waarom ga ik niet terug?");
PadMain.GameStateManager.SwitchTo("Playingstate");
}

if (betalen.Pressed)
{
PadMain.GameStateManager.SwitchTo("Laptopstate3");
}

if (negeren.Pressed)
{
PadMain.GameStateManager.SwitchTo("Playingstate");
}

/*//Begin van: Mail aanklikken -> Archiveren of weggooien.
* Crasht, geen idee waarom.
*
if (btnMail.Pressed)
{

btnTrash = new Button("sprTrash", 1);
btnTrash.Position = new Vector2((PadMain.Screen.X / 2) - 150, (PadMain.Screen.Y / 2) - 100);
this.Add(btnTrash);

btnArchive = new Button("sprArchive", 1);
btnArchive.Position = new Vector2((PadMain.Screen.X / 2) - 150, (PadMain.Screen.Y / 2) + 100);
this.Add(btnArchive);

}
*/
base.HandleInput(inputHelper);
}

}
}

 

---

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;

namespace PadGame
{

class RandomEvent
{

Random random = new Random();
int randomInterval;

public void Main()
{

randomInterval = random.Next(5000, 10000);
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = randomInterval;
aTimer.Enabled = true;

}

// Specify what you want to happen when the Elapsed event is raised.
public void OnTimedEvent(object source, ElapsedEventArgs e)
{
Mailstate mailState = new Mailstate();
mailState.newMail = true;
Console.WriteLine("RandomGenerator CHECK... : " + randomInterval / 1000 + " seconds have passed since the last check.");
randomInterval = random.Next(5000, 10000);

}
}
}

"Pants? You mean leg prisons."

May 25, 2015
5:59 pm
AdmlAdama
Member
Members
Forum Posts: 111
Member Since:
April 21, 2015
sp_UserOfflineSmall Offline

Let me finish this movie and we can do skype where I can walk you through the editor in order to debug this program step by step.

May 25, 2015
6:01 pm
tedisvet
The Netherlands
Member
Members
Forum Posts: 135
Member Since:
February 19, 2015
sp_UserOfflineSmall Offline

Allright :) Take your time!

"Pants? You mean leg prisons."

May 25, 2015
7:06 pm
AdmlAdama
Member
Members
Forum Posts: 111
Member Since:
April 21, 2015
sp_UserOfflineSmall Offline

So your if is probably evaluating to true but your for loop has a problem

for (int i = 0; i < 0; i++)


So the 3 parts of a  for loop are this

for (iterator; condition; increment)

 

So, in pseudo english

use an int called i 

set i to 0

As long as i is less than 0 (such as -1, -2, -3) then

  • do the loop
  • add 1 to i
Forum Timezone: America/New_York

Most Users Ever Online: 117

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Emulated: 3206

ryanpitts: 1300

Dalferes: 746

Pherian: 660

Okarim: 593

Member Stats:

Guest Posters: 10

Members: 3268

Moderators: 3

Admins: 2

Forum Stats:

Groups: 8

Forums: 45

Topics: 6229

Posts: 27382

Newest Members: KeroNop, AndrewElula, Besoscb, caseyfi60, JerryStype, tyroneyh18, RosarioKak, gailot69, RubenPOf, EdwardSaurf, clairert4, Besosze, WyomingKn, RomaChode, Mauricedag, clydepf18, guytx11, Genarofus, KevinDaw, JamesDaynC

Moderators: terrorisly: 424, mudwog: 127, LightWarriorK: 2144

Administrators: meatbawllz: 2475, frelling: 3263