Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 35 36 [37] 38 39 ... 91

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

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #540 on: February 19, 2012, 09:05:42 pm »

So, how would I go about drawing an image (in Java).
Currently, the relevant part of the code is:

Code: [Select]
private void gameRender(){
if (dbImage == null){
dbImage = createImage(PWIDTH, PHEIGHT);
if (dbImage == null){
System.out.println("dbImage is null");
return;
} else {
dbg= dbImage.getGraphics();
}
}

//clear screen
dbg.setColor(Color.white);
dbg.fillRect(0, 0, PWIDTH, PHEIGHT);

//So how would I add an image here?
   
    }

} // End of gameRender


I have an image, let's say tree.png. How would I add 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

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #541 on: February 19, 2012, 09:14:31 pm »

He could also consider using something like int(#/2)-5, then.

If OP is so concerned to get 9 ending up as -1, I'm thinking that the sourcebook maths/tables probably work on this basis.  Doing an integer division of the whole-number-positive then dragging the lesser numbers into negative territory as much as it drags the higher numbers into not-so-higher territory, but retaining an equal number of multiple-to-one mapping in for all X->Y (in this case, 2 Xs for every Y, something that classically integering (#-10)/2 would not do for the same range.

But, of course, floor's bias towards the more negative/less positive does this.

Anyway, that's a lot of waffle.  (Sub-)Topic closed? ;)


What's wrong with
Code: [Select]
(#==9)? -1 : #;except that it looks like brainfuck?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #542 on: February 19, 2012, 09:16:32 pm »

If (# is equal to 9) return -1, else return #.
Not exactly brainfuck stuff...

Starver

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #543 on: February 20, 2012, 07:19:13 am »

You know, I'm so used to doing stuff in Perl that isn't (as easily, or so similarly) possible in any 'proper' dialect of C, that I'd never even considered using the ?: notation, even though I've been using it heavily (in Perl) over the last 48 hours.

But if 9 must end up as -1 (where OP's original formula would not have done), I'm suspecting that 7 must end up as -2 as well (where OP's original formula would not have done, but where it should have landed regardless).  And while 7 might be considered 'out of range', I don't think we can exclude the possibility that it somehow finds its way into range (like I said before, a poison effect reducing STR below my presumed normal minimum value of 8).  If the floor() version from Mephisto or my rearrangement version with the int()ed division then minused both give valid results for 9, I suspect they'll give valid results for 7[1] as well.  Without any "special case" handling needed at all.


[1] And 5 and 3 and 1, and I feel reasonably confident that there'd be no -1 base Strength, so we can stop there, although Mephisto's version will continue to do what I think it ought to do, however much 'out there' we might ever find ourselves needing to cater for...
Logged

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #544 on: February 20, 2012, 09:49:38 pm »

Does anyone know Visual BASIC here or Small BASIC?

If so I would ask of someone to direct me to or give me the command that allows one to open other programs.


I don't seem to be able to find it on the internet.
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #545 on: February 20, 2012, 09:56:16 pm »

System.Diagnostics.Process.Start(filelocation)
I'm pretty sure, try it anyway.

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #546 on: February 20, 2012, 10:27:14 pm »

It does not work. It may be because I'm using the smaller more 'new' programmer friendly Small BASIC. It does not have everything Visual BASIC does.

There is the command:

File.ReadContents(filepath)

But it only reads the file and I can't figure out how to get it to display the contents or draw from it.
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #547 on: February 20, 2012, 10:30:39 pm »

Ah, if you are using small basic, instead of visual basic, I don't like your chances. Small basic is very limited in functionality by design choice. What do you plan on doing with it?

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #548 on: February 20, 2012, 10:35:11 pm »

The program I'm making or Small BASIC?

I would get Visual BASIC but it costs $130 I think and I'm not sure if that's a good investment yet.

Yes Small BASIC is very annoying but it helped me learn. Didn't like C++ to much, too many brackets and too much code for something as simple as "Hello World" (C++ is a very powerful language though). I do like Python and am still learning about it, which is why I got Small BASIC.
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #550 on: February 20, 2012, 10:43:08 pm »

I looked at that on a different site before but the creator didn't have enough data to let that many people download it.

Thank you so much.

Looks appetizing.
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #551 on: February 20, 2012, 10:48:24 pm »

Don't thank me, thank the good people over at Microsoft! Building a brighter tomorrow, today!


There, I did my part of the deal, now give me my soul back!
NEVER!!!

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #552 on: February 20, 2012, 10:56:50 pm »

I bought darkBASIC a very long time ago, and didn't like it. I was like 13 at the time.
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.

Chaos Armor

  • Bay Watcher
  • Grand Master Lurker
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #553 on: February 20, 2012, 11:00:59 pm »

It's one of those trial versions Max.

I love Microsoft!
Logged
Lurking since 2009

Leerooooooooy walk forward twice

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #554 on: February 20, 2012, 11:05:19 pm »

Na, it is an express version. It never runs out, and it can do everything programming wise, but it doesn't have all the really cool IDE functionality of the pro version. For example, it won't draw your class diagram for you, and you can't program with a friend over the network, but for your needs it is perfect.
Pages: 1 ... 35 36 [37] 38 39 ... 91