Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 38 39 [40] 41 42 ... 91

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

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #585 on: March 13, 2012, 09:50:37 pm »

Ah, yes. Before I added the menus ect. the input worked just fine. And sorry if my code is bad practice- This is my first real project in Java. The only language I really know is Python (and even that not too well). I really just program as a hobby for now. Maybe once I go to college I'll get more serious about it.
Logged
I don't care about your indigestion-- How are you is a greeting, not a question.

The epic of Îton Sákrith
The Chronicles of HammerBlaze
My website - Free games

eerr

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #586 on: March 14, 2012, 02:34:48 am »

*Don't store the playlistener in gameWindow.
I removed it, that worked.

That appears to be all, I guess.

Tell me if that doesn't work.
Logged

Starver

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #587 on: March 14, 2012, 07:06:41 am »

Sorry, don't want to interrupt this other thread-with-the-thread, but while I'm thinking about it, I thought I'd put forward a quick question[1] about GIMP and Script-Fu, for anyone with a finger well and truly within that particular pie:  I want to know if I'm right that it appears that the standard Scheme(i.e. SIOD) functions/defines that are in-built to GIMP do not include arbitrary direct file-reading capabilities.  i.e. the (fopen <path> <mode>) and (read[line] <stream>) functions, or similar.

It doesn't even appear to have (apropos <substring>) defined, in order to search for possible alternatives, and attempted Script-Fu console use of them suggests that they're missing, rather than that I'm not parametrising them correctly.

As I want to import (and pre-process via Script-Fu, that's easily done) some textual data in various ways (ideally, specifying an input file in a text-type field for, for menu-activated use of the fully-registered extension), it looks like I need to go for a full-blown compiled plug-in (or perhaps Perl-Fu...  Perl seems to be my default fall-back at the moment, anyway!) either to do the whole job, or just to implement a function that bridges the gap between the 'missing' data-input procedures and the Script-Fu I've already written that translates data to the required effect.

Like the Script-Fu, my Google-Fu also hasn't helped me much.  I'm thinking that this is probably because no-one (that I've seen!) has explicitly said it isn't possible, rather than because no-one has described what is possible in ways that my various refined search queries have matched well with, via the usual search methods.

(I was also kind of hoping that there'd be an easily portable method of making my GIMP extensions easily adoptable by others, once I got them doing what I wanted them to do, but if it goes so far as to need each person to 'make' at least some of the file components, that puts a small and yet not insignificant barrier in the way of ease-of-use by an 'everyman'.  But I'm not au fait with anything other than homegrown scripting, within this particular environment, so I suppose it may be a lot easier than I'm fearing.)



[1] Here in a place I already can easily post to, rather than have to register for a new forum that I'm probably not going to want to say much on, beyond the point I've confirmed my suspicions.
Logged

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #588 on: March 14, 2012, 10:42:58 am »

*Don't store the playlistener in gameWindow.
I removed it, that worked.

That appears to be all, I guess.

Tell me if that doesn't work.

Hmm... I made the PlayListener into a new class, but though the game still ran, the keyboard still didn't work. I didn't detect any difference.

Logged
I don't care about your indigestion-- How are you is a greeting, not a question.

The epic of Îton Sákrith
The Chronicles of HammerBlaze
My website - Free games

eerr

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #589 on: March 14, 2012, 12:05:41 pm »

Code: [Select]
Class Gamewindow
     //PlayListener playlistener = new playlistener();

That is what I meant.
« Last Edit: March 14, 2012, 12:08:08 pm by eerr »
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #590 on: March 14, 2012, 02:57:56 pm »

[script-fu stuff]

Admittedly, I don't much know what you're talking about. My GIMP skills are limited to simple image editing.

My Google-Fu lead me to this. It's for a slightly older version of GIMP. I'll quote the one relevant portion here:
Quote
Deprecated features

The following SIOD functions or constants are currently made available in TinyScheme Script-fu but may disappear in future versions.
[snip]
fopen - replaced by TinyScheme's open-input-file
[snip]
Logged

Starver

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #591 on: March 14, 2012, 06:32:15 pm »

Quote
Deprecated features

The following SIOD functions or constants are currently made available in TinyScheme Script-fu but may disappear in future versions.
[snip]
fopen - replaced by TinyScheme's open-input-file
[snip]
Hmm, looks promising...  Like a lot of inbuilt functions it's not in the (GIMP) procedure browser, but:
Quote from: console
> (open-input-file "." "r")
Error: open-input-file: needs 1 argument(s)

> (open-input-file ".")
#f
Right, so having tried a directory (which I knew would be wrong), I think I've got the format.  Now... where does it look by default?

No, forget that, I can just specify it absolute with (open-input file "c:/...something or other...") and if it's an existing file I get a response #<PORT>, and tests show that (read ...) accepts one parameter, which might well be a variation on that <PORT>, but I'm getting "undefined sharp expression" if I include the "#" and "unbound variable" for the other ways I've tried to use it (but "Error: read: argument 1 must be: input port" is definitely what it wants).  Time for me to chase down the TinyScheme documentation, at least one version of which you appear to have found that I didn't, or otherwise investigate the Stream-variable syntax relevant to this particular situation.

So cheers for that.  Loads of help.  I'd just about decided that an alternate way of dealing with the problem is to externally 'pre-dope' the script that I was going to load with effectively embedded data.


edit: I'm an idiot...  One assigns the (open-input-file ...) result to a variable and use that in the read (or use it directly, if you're just bothered with the first line of output).  Right, cooking on gas.  Except that I'm nowhere near the computer on which I've got all the stuff I want to process, so trying it out for real will have to wait...
« Last Edit: March 14, 2012, 06:42:51 pm by Starver »
Logged

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #592 on: March 20, 2012, 01:55:39 pm »

How do I show the results of two queries side by side? I have two separate queries that look like this:
Code: [Select]
SELECT Teacher.[Last Name] & ", " & Teacher.[First Name] AS [Too Old], DateDiff("yyyy", Teacher.[Birth Date], Date()) AS Age
FROM Teacher
WHERE DateDiff("yyyy", Teacher.[Birth Date], Date()) > 70;
and this:
Code: [Select]
SELECT Teacher.[Last Name] & ", " & Teacher.[First Name] AS [Too Young], DateDiff("yyyy", Teacher.[Birth Date], Date()) AS Age
FROM Teacher
WHERE DateDiff("yyyy", Teacher.[Birth Date], Date()) < 20;

And I want them to show side by side (i.e. Too Old, Age, Too Young, Age). A simple union doesn't do the trick.
Logged

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: Programming Help Thread (For Dummies)
« Reply #593 on: March 21, 2012, 01:15:43 am »

I have a quick question... I am using Visual Studio C++ 2010 Express but only have the free license for it so cannot use the Resource Editor thingy. Is there a non-glitchy-as-hell resource editor that will work with 64-bit Win 7?

GalenEvil
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

olemars

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #594 on: March 21, 2012, 03:11:22 am »

I have a quick question... I am using Visual Studio C++ 2010 Express but only have the free license for it so cannot use the Resource Editor thingy. Is there a non-glitchy-as-hell resource editor that will work with 64-bit Win 7?

GalenEvil

Notepad?
Depends what sort of resources you're trying to add, but the .rc files aren't that complicated so if it's just an icon or similar you might as well just handcraft the script.
Logged

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #595 on: March 21, 2012, 08:39:31 pm »

So now I'm working on another project: a program that locks files. I'm not running into any programming issues; rather I want to know how I can set the permissions(or something similar) on a file so that only my program (which is is Python) can open it. It would be great if there was a way to do this inside of my program, but I am happy to just right-click and change whatever permissions are needed manually. Thanks.
Logged
I don't care about your indigestion-- How are you is a greeting, not a question.

The epic of Îton Sákrith
The Chronicles of HammerBlaze
My website - Free games

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: Programming Help Thread (For Dummies)
« Reply #596 on: March 22, 2012, 12:28:22 am »

I have a quick question... I am using Visual Studio C++ 2010 Express but only have the free license for it so cannot use the Resource Editor thingy. Is there a non-glitchy-as-hell resource editor that will work with 64-bit Win 7?

GalenEvil

Notepad?
Depends what sort of resources you're trying to add, but the .rc files aren't that complicated so if it's just an icon or similar you might as well just handcraft the script.

Oh lolz... I've never looked at resources outside of an IDE. What I am needing to do is make a dialog, so I guess I will look through some old dialogs and see if I can work out how to get the dialog the way I want it to look that way
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #597 on: March 27, 2012, 09:42:02 pm »

I have a question. Now this is probably one of the most stupidest questions you've gotten yet but...


Spoiler: Code (click to show/hide)

How can I get this program to open the programs that have been assigned those variables when I click the "OK" button.

NOTE: This is not a text based window. It is a graphical window. It has check boxes.

Thanks.
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #598 on: April 15, 2012, 05:59:07 pm »

Hello again,
I'm having trouble playing sounds inside JAR files. The code looks like this:

Code: [Select]
// Within some mass of code:

SoundClipTest player = new SoundClipTest();
player.playSound("Pop.wav")


public class SoundClipTest extends JFrame {

// Constructor
public SoundClipTest() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Test Sound Clip");
this.setSize(10, 10);
this.setVisible(false);
}

public void playSound(String fileName){

try {
// Open an audio input stream.

URL url = this.getClass().getClassLoader().getResource(fileName);
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url); //*

// Get a sound clip resource.
Clip clip = AudioSystem.getClip();
// Open audio clip and load samples from the audio input stream.
clip.open(audioIn);
clip.start();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}

}
* what happens here is I get a nullPointerException
Spoiler: Error Message (click to show/hide)

What am I doing wrong?

By the way, I did Google this, but clearly my Google-fu is not up to snuff, as all the things I found either didn't work or I was not sure how to use them.
« Last Edit: April 15, 2012, 06:03:25 pm by Kofthefens »
Logged
I don't care about your indigestion-- How are you is a greeting, not a question.

The epic of Îton Sákrith
The Chronicles of HammerBlaze
My website - Free games

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #599 on: April 15, 2012, 09:01:23 pm »

Well, getResource returns null if the resource name passed to it doesn't exist, so there is probably something wrong with fileName.
Logged
Pages: 1 ... 38 39 [40] 41 42 ... 91