Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 27 28 [29] 30 31 ... 91

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

Antsan

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #420 on: January 26, 2012, 03:48:44 am »

Quote
but without a middle point you only have 2 points, not 3
Hu? Hadn't you given 3 points?
Quote
(10;353), (260;3) and (530;353)
Did I misinterpret this?
The third point doesn't need to be the vertex.

Quote
a = ((height*2) / (((distance/2)*(distance/2))*2));
reduce to: a = 4 * height / distance^2
Quote
b = ((height * -2)/ (distance/2))
reduce to: -4 * height / distance

Quote
(opens upwards though because for the SDL graphical library up is down in regards to graphs, example y=200 would be lower than y=20)
Ah, that makes sense.

But then again (in the case of three given points, which I thought was the original problem) you would have to subtract (with the inverted y-axis you use, alse you would have to add) the height of the ground from the parabola to calculate the actual intercepts. In the case you get imaginary values the throw is done below ground.
Logged
Taste my Paci-Fist

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #421 on: January 28, 2012, 11:31:20 am »

This thread is interesting.
I'll have to keep this in my bookmarks just in case I need to ask something obvious :P
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

Supermikhail

  • Bay Watcher
  • The Dwarf Of Steel
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #422 on: January 29, 2012, 05:46:21 am »

I've got some problem and this might be the place to ask about it (or it might not be). But I'm quite a dummy regarding programming, so I'll give it a try.

I want to make a program that takes words out of a text file, arranges them into random combinations and outputs them as an Ubuntu notification at regular time intervals. I've coded spuriously in Java for a year, if that's worth something, so I could get as far as "takes words and arranges them in random combinations", although it would probably take considerable amount of research. For Ubuntu notifications I'm clueless, though. Am I even equipped close to right for it? I imagine I could devote some time to learning things necessary to do it (like C instead of Java, e.g.), because I think it's worthwhile.

I'd appreciate any advice. Also, maybe there's a more suitable place to ask this question (possibly not even on this forum)?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #423 on: January 29, 2012, 06:05:21 am »

Combine perl, a cron job, and a shell script?
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))

Supermikhail

  • Bay Watcher
  • The Dwarf Of Steel
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #424 on: January 29, 2012, 06:58:31 am »

Wow... Does "cron job" mean just "cron program" or something, or is there a more specialized meaning, so to say?

Also, wow... No easier way? I mean it's three new languages, basically. Will I be able to hack it up with half-a-year of consistent learning?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #425 on: January 29, 2012, 07:43:09 am »

Hehe, no, Cron is a program that can run other programs at set intervals, a shell script is like an MSDOS batch file: It generally just runs other programs, you might not even need it, and perl is nice when working with large amounts of string data, but that one's interchangeable, so you could do it in Java if you know how to do it.

So you edit your crontab (google that), and add to it something like
Code: [Select]
0 * * * * /usr/local/jobthatprintsmessage.pl | notify-sendBut I'm not a *NIX expert, this is a rough example.
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))

Supermikhail

  • Bay Watcher
  • The Dwarf Of Steel
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #426 on: January 29, 2012, 08:22:08 am »

Thanks. I'm not sure, though, that launching the program each time I'm to get my dose is a good idea. Especially if then I'd need to programmatically shut it down, and I fear it's another can of worms (at least based on my Java experience). I wish I could make it run in the background or whatever programs at the top-right are doing (maybe it's the notification area). Like Tomboy notes. I think it's gonna be harder to do... Much harder. Yeah, thanks for the tips.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #427 on: January 30, 2012, 08:20:40 pm »

Something like that could be way easier than you think.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #428 on: January 30, 2012, 09:19:38 pm »

Thanks. I'm not sure, though, that launching the program each time I'm to get my dose is a good idea. Especially if then I'd need to programmatically shut it down, and I fear it's another can of worms (at least based on my Java experience). I wish I could make it run in the background or whatever programs at the top-right are doing (maybe it's the notification area). Like Tomboy notes. I think it's gonna be harder to do... Much harder. Yeah, thanks for the tips.

You could make the program run in the background periodically printing out words, but why bother? With the cron job mentioned earlier, the specified time would come around, cron would fire off your job, your job would execute, and then execution would cease. I'm not sure what you mean by "programmatically shut it down."

The only issue I foresee is the job would be firing even when no one is using the computer.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #429 on: January 31, 2012, 04:22:39 am »

You could make the program run in the background periodically printing out words, but why bother? With the cron job mentioned earlier, the specified time would come around, cron would fire off your job, your job would execute, and then execution would cease. I'm not sure what you mean by "programmatically shut it down."

Of course if you used the cron.d directory instread of crontab directly then you can programmatically shut it down by changing the execute flag on your job.

However if you want to run in the background the quickest way would be to add an & after your command line. This will return you the pid for the newly spawned process.
Sleeping in most languages is trivial so you can duplicate what cron does that way.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Scelly9

  • Bay Watcher
  • That crazy long-haired queer liberal communist
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #430 on: January 31, 2012, 11:32:24 am »

Ok, supernewby time:
Why won't this code run? It's in Python, by the way.
Quote
print "********************************"
passguess = input("please enter password: ")

if passquess == 1
  print "Correct!"

else
  print "LOCKED OUT!"

It's giving me a syntax error.
Logged
You taste the jug! It is ceramic.
Quote from: Loud Whispers
SUPPORT THE COMMUNIST GAY MOVEMENT!

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #431 on: January 31, 2012, 12:08:56 pm »


Quote
print "********************************"
passguess = input("please enter password: ")

if passquess == 1:
  print "Correct!"

else:
  print "LOCKED OUT!"

Needs colons.  I added some.
« Last Edit: January 31, 2012, 12:10:46 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #432 on: January 31, 2012, 12:13:30 pm »


Quote
print "********************************"
passguess = input("please enter password: ")

if passquess == 1:
  print "Correct!"

else:
  print "LOCKED OUT!"

Needs colons.  I added some.

There is a simple typo as well. passguess is assigned, passquess (note the q instead of a g) is used.

passguess will never equal 1 unless you cast or parse it. What may be desired is
Code: [Select]
if passguess == '1':
or something similar.
Logged

Xegeth

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #433 on: January 31, 2012, 12:17:16 pm »

I believe the way you're using input is also causing problems. input runs eval on the result, but you just want to assign a value to passguess so you should use raw_input instead.

Edit: That's assuming you're using python version 2 and not version 3 by the way.
« Last Edit: January 31, 2012, 12:21:24 pm by Xegeth »
Logged

Scelly9

  • Bay Watcher
  • That crazy long-haired queer liberal communist
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #434 on: January 31, 2012, 12:28:01 pm »

Ok, thanks a lot! I shall now go edit my program.
Logged
You taste the jug! It is ceramic.
Quote from: Loud Whispers
SUPPORT THE COMMUNIST GAY MOVEMENT!
Pages: 1 ... 27 28 [29] 30 31 ... 91