Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 48 49 [50] 51 52 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 100795 times)

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #735 on: July 02, 2012, 05:40:48 pm »

I wanted to ask, what is Console.SetBufferSize(x, y) for?

SetBufferSize is similar to SetWindowSize. Window size controls the size of the window, obviously, but buffer size controls the size of the data within the window. For example, if window size is (80 , 25) and buffer size is (80 , 300), you should be able to scroll up and down.

If may know about this already, but you can click on the icon in the top left of the console window, click Properties, go to the Layout tab and adjust buffer size and window size there. It may be useful for experimenting with stuff.

Also, I would like to point out that you can go to the Font tab and change it to a square font. I don't know about you, but rectangular fonts bug the crap out of me when playing ASCII games.
Logged

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #736 on: July 02, 2012, 06:02:48 pm »

Ah thanks, it will allow me to make stuff like scrolling around a bigger global map without redrawing the whole screen, right?

I've been freaking out with the menu and random quotes and it took the whole evening. Man, I should make all needed basics first and work on cosmetics later :D.

At least I now have a working UI for the menu (which needs a lot of details added).

Spoiler (click to show/hide)

P.S. Random.Next seems to be really bad with small numbers, also Random.next(a,b) seems to be quite weird with the "middle" numbers... Can you suggest a randomization algorythm I could use in the roguelike?
« Last Edit: July 02, 2012, 06:22:53 pm by Deon »
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Draxis

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #737 on: July 10, 2012, 11:28:55 am »

So I have this Java code.  in.nextInt() calls a Scanner object to read an integer from System.in, and throws an InputMismatchException if it encounters other characters.  It works fine unless the exception is thrown, in which case it completes the first iteration fine, and then continues throwing the exception on each iteration without taking input.   Does anyone know what the problem is?
Code: [Select]
int distChoice = -1;
System.out.print("NO. OF ROOMS(1-5)?");
while (distChoice < 1)
{
    try
    { 
        distChoice = in.nextInt();
        if (distChoice < 1) distChoice = -1;
        else if (distChoice > 5) distChoice = -1;
    }
    catch (InputMismatchException e)  {  distChoice = -2;  }
    if (distChoice == -1) System.out.print("NO. OF ROOMS(1-5)?");
    else if (distChoice == -2)
    {
        System.out.print("??");
        distChoice = -1;
    }

}   
Logged

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #738 on: July 10, 2012, 11:55:50 am »

What is possibly happening is that when the exception is thrown, nextInt() doesn't clear the input stream of what it read so each call to nextInt tries to read the same thing over and over again. I'm too lazy to confirm this though.

As an alternative to throwing/catching exceptions, you should be using Scanner.hasNextInt(). Exceptions are generally reserved for more serious errors where normal program flow has to be interrupted to deal with it.
« Last Edit: July 10, 2012, 11:57:28 am by Normandy »
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #739 on: July 10, 2012, 12:16:47 pm »

When a scanner throws an InputMismatchException, the scanner will not pass the token that caused the exception, so that it may be retrieved or skipped via some other method.
Seems like you need to clear the offending bytes by hand.
Logged

Draxis

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #740 on: July 10, 2012, 12:18:12 pm »

Thanks, I fixed it by using hasNextInt() and calling nextLine() to clear it if it did not.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #741 on: July 18, 2012, 06:29:41 am »

I have a decision to make, both options have their pros and cons.  i'm trying to decide if I should learn win32 GUI programming so I can make a 2d map editor for a game I'm making, but the thing is I'm planning on ending up making the levels procedurally generated, but I need a map or two made for when I am doing tests and making the game other than the world / level gen.
Pros to this option would be, I'd learn win32 GUI programming, in case I ever want or need to make another program that isn't a game.  And I could use it again down the road for any other projects with slight changes that wouldn't be hard to make.
My other option would be to just code a level editor right into the game, which would be easier, and then take it out eventually.
and really my other other option would be to just make the levels using notepad, but that would be booooring, well and confusing.
i'm thinking about doing the win32 gui route but I need someone to tell me it's a good idea.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #742 on: July 18, 2012, 12:09:05 pm »

By Win32 GUI do you mean the controls provided by WinAPI, WinForms, or WPF?

WinAPI - I would say don't bother. If you're just going to be a hobbyist, save yourself the trouble, and if you're going to work in industry, you'll be hard pressed to find anyone who still uses the GUI controls of WinAPI.
WinForms - This is probably the one with the shallowest learning curve: just download Visual Studio Express and use the visual designer. You can then slowly learn new features by playing around with the controls.
WPF - So WinForms and WPF are actually pretty similar in terms of functionality, but WPF probably has a larger learning curve because controls are written in XAML (a variant of XML) so it takes some getting used to. WPF also has some nifty additional features, but I'm not familiar enough with it to tell you about them. Visual Studio Express also has a visual editor for WPF.

My overriding recommendation if you plan to use these GUI controls is to use a visual editor, like visual studio. You'll work and learn a lot faster that way.

You might also want to look into 3rd party GUI libraries that are cross-platform; but my experience with those is that usually they take a while to set up and using WinForms or WPF in Visual Studio is so much more convenient if you're not worried about cross-platform issues.
« Last Edit: July 18, 2012, 12:11:29 pm by Normandy »
Logged

Thendash

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #743 on: July 18, 2012, 11:37:31 pm »

That feeling when you catch yourself having a conversation with yourself via comments.

C#: How would I go about loading all the images from a folder into an ArrayList without knowing the filenames or the amount of files in the content folder?
Logged
Thendash's Livestream

This game could honestly give out hand jobs for free and people would still bitch.

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #744 on: July 19, 2012, 12:04:20 am »

Do you know the extensions? If so, you could do what's in the first answer over here (minus the xml-specific bits). Note: uses .Net 4.0 features.
Logged

Neonivek

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #745 on: July 19, 2012, 12:09:13 am »

Hmm I could ask a question... but currently if I used the law of statistics and programmed it into my computer it would say I have a 0% chance of genuinly getting help.

So I won't.
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #746 on: July 19, 2012, 12:23:31 am »

Hmm I could ask a question... but currently if I used the law of statistics and programmed it into my computer it would say I have a 0% chance of genuinly getting help.

So I won't.

Then what was the point of even posting? Other people (like Deon) are getting help here just fine.

Although if you're looking for help on your obscure adventure game engine you're probably right. I use AGS for the few tests I've programmed.
« Last Edit: July 19, 2012, 12:28:23 am by freeformschooler »
Logged

Neonivek

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #747 on: July 19, 2012, 12:30:05 am »

Hmm I could ask a question... but currently if I used the law of statistics and programmed it into my computer it would say I have a 0% chance of genuinly getting help.

So I won't.

Then what was the point of even posting? Other people (like Deon) are getting help here just fine.

Of course Deon is getting help just fine. He is asking for very specific programming questions. I am not talking about it in those terms.

As for why post... To state it. To state really. It must be stated it must be said at least once.
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #748 on: July 19, 2012, 12:33:31 am »

Hmm I could ask a question... but currently if I used the law of statistics and programmed it into my computer it would say I have a 0% chance of genuinly getting help.

So I won't.

Then what was the point of even posting? Other people (like Deon) are getting help here just fine.

Of course Deon is getting help just fine. He is asking for very specific programming questions. I am not talking about it in those terms.

As for why post... To state it. To state really. It must be stated it must be said at least once.

Well, I have nothing better to do at the moment, so I volunteer to help research whatever your problem is. We can take it to PMs if it ends up being lengthy.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #749 on: July 19, 2012, 02:57:06 pm »

Often when asking for help here I find the answer just by typing the question. It happens on the job a lot, where someone asks for my help/input, I just listen, and after explaining what they need they already found the answer themselves. I provide this service for free on a distance, as well ;)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))
Pages: 1 ... 48 49 [50] 51 52 ... 91