Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 32 33 [34] 35 36 ... 91

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

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #495 on: February 09, 2012, 03:47:37 pm »

No, I don't need it, I have it ;) Diamond square can **** my mother****ing ****. Once I have a terrain that I like, the actual abstraction of detail is inherent to the process.

Right now I've got a hilly sphere (Note that the distance-detail thing is not obvious here, it's a sphere of 6 meters diameter Edit: I mean radius). It's time to increase the scale and optimise the vertexgeneration.
Spoiler (click to show/hide)
« Last Edit: February 10, 2012, 03:33:30 am by Siquo »
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))

DeKaFu

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #496 on: February 09, 2012, 05:41:30 pm »

Hoping this is a good place to put this?

So here's my situation:

My whole programming experience is one and a half semesters of introductory programming, and the language I've learned is C.
I've been working on a very simple (first!) game. Right now it's not a game so much as a non-interactive simulation that runs once and prints, but anyway...

I basically want to take what I have now and build a sorta virtual pet thing around it wherein you'd have many pets at once. I don't currently know how to do this, but I'm looking ahead and wondering if I should keep working on it as it is in C, or try to learn C++ and object-oriented stuff and continue from that direction.

The idea of learning a new language at this point when I'm not even fully competent with my first is pretty daunting, but maybe it'd make things easier in the end? I don't know. I was planning to make it run in the console but am kinda hopeful I could give it (simple, 2D) graphics someday.

FWIW I'm probably going to have to completely rewrite what I have already either way, considering I wrote the whole thousand lines of it before learning that pointers, memory allocation and structs are things that exist.

So, advice please?
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 #497 on: February 09, 2012, 08:36:26 pm »

I've made a 2d game in c++ without knowing any of the object oriented aspects of it.
so it's not impossible to make a game without object oriented stuffs.

I say go with what you know, if you're comfortable in C, stay in C.

learning a 2d graphical library is almost as much work as learning a new language.
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.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #498 on: February 10, 2012, 03:32:39 am »

I'd say switch. C++ isn't that different from C, and if you ever want to do anything cool, it's better equipped than C. OTOH, if you want quick results, keep what you have and try to work with that. Working on something for a long time with lots of frustration with no results can be off-putting.
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))

Shades

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #499 on: February 10, 2012, 03:59:13 am »

I'd say code in a functional c style but leverage the built in (and maybe boost) c++ artifacts. The stl containers, threading and exception handling are trival to use and far superior to there c counterparts.
Switch to c++ as you need/want to 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

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #500 on: February 10, 2012, 11:24:39 pm »

In Java: I'm having trouble removing components from a JFrame.

A super-condensed version of the important parts of the code:

Code: [Select]
public class GameWindow extends JPanel implements runnable{

JFrame window = new JFrame();
Box buttonBox; // This has buttons added to it in an irrelevant part of the program

public void run(){
       window.getContentPane().remove(buttonBox);
       window.getContentPane().add(this);

       // more, irrelevant code
}

public void gameOver(){
       window.getContentPane().remove(this);
       window.getContentPane().add(buttonBox);

       // more, irrelevant code
}

}

However, it doesn't seem to be removing the buttonBox or this
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 #501 on: February 10, 2012, 11:31:52 pm »

From the official documentation (at least I think it's official), you need to call validate on window.getContentPane() after you add and remove those components.
Logged

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #502 on: February 10, 2012, 11:49:49 pm »

That did the trick, 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

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #503 on: February 12, 2012, 09:50:25 am »

How Can I tell if a float is an interger? Ex.) if (dValue = {wholenumber}), is there an operater I can use? scratch that I fixed
it

EDIT: whats wrong with this program?

Spoiler (click to show/hide)

I'm not sure what causes the error for the operator. i've had this problem a couple of times.
Also note, that although #include <iostream> is not shown its there.
« Last Edit: February 12, 2012, 11:40:21 am by Urist McScoopbeard »
Logged
This conversation is getting disturbing fast, disturbingly erotic.

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #504 on: February 12, 2012, 12:20:23 pm »

How Can I tell if a float is an interger? Ex.) if (dValue = {wholenumber}), is there an operater I can use? scratch that I fixed
it

EDIT: whats wrong with this program?

Spoiler (click to show/hide)

I'm not sure what causes the error for the operator. i've had this problem a couple of times.
Also note, that although #include <iostream> is not shown its there.

Remove the endl on your cin.

Also, this form of recursion is odd.
« Last Edit: February 12, 2012, 12:22:22 pm by Mephisto »
Logged

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #505 on: February 12, 2012, 12:23:54 pm »

Thanks that worked
Logged
This conversation is getting disturbing fast, disturbingly erotic.

Shades

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #506 on: February 12, 2012, 02:01:06 pm »

Also that tabbing might get confusing as the cout << main(); is not part of the else even though it looks like it is.
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

Kofthefens

  • Bay Watcher
  • Keep calm and OH GOD CAPYBARAS
    • View Profile
    • Marshland Games
Re: Programming Help Thread (For Dummies)
« Reply #507 on: February 12, 2012, 03:51:41 pm »

Strangely enough my program isn't registering keyboard input. Can anybody figure out why? This in Java, by the way.

Code: [Select]
public class GameWindow extends JPanel implements Runnable {
        public GameWindow(){
                setFocusable(true);
requestFocus();
addKeyListener(new KeyHandler());
        }

        public void run(){
int period = 20;
long beforeTime, timeDiff, sleepTime;

beforeTime = System.currentTimeMillis();

running = true;


while (running){

gameUpdate();
gameRender();
paintScreen();

if (leftPressed){
leftArrowKeyPressed();
}

if (rightPressed){
rightArrowKeyPressed();
}

if (readyToClose){
gameOver();
}

//requestFocus();

timeDiff = System.currentTimeMillis() - beforeTime;
sleepTime = period - timeDiff;

if (sleepTime <= 0){
sleepTime = 5;
}

try{
Thread.sleep(sleepTime);
}catch (InterruptedException ex){}

beforeTime = System.currentTimeMillis();


if (gameIsOver){
gameOver();
}

}

} //End of run()

public class KeyHandler extends KeyAdapter{

public void keyTyped(KeyEvent e){
int keyCode = e.getKeyCode();
if((keyCode == KeyEvent.VK_ESCAPE) || (keyCode == KeyEvent.VK_Q) ||
(keyCode == KeyEvent.VK_END) ){

readyToClose = true;
}
}

public void keyPressed(KeyEvent e){
int keyCode = e.getKeyCode();

if (keyCode == KeyEvent.VK_LEFT){
leftPressed = true;
//System.out.println("left");
}
else if (keyCode == KeyEvent.VK_RIGHT){
rightPressed = true;
//System.out.println("Right");
}
}

public void keyReleased(KeyEvent e){
int keyCode = e.getKeyCode();

if (keyCode == KeyEvent.VK_LEFT){
leftPressed = false;
//System.out.println("left");
}
else if (keyCode == KeyEvent.VK_RIGHT){
rightPressed = false;
//System.out.println("Right");
}
}


}

}
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

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #508 on: February 12, 2012, 04:41:21 pm »

Strangely enough my program isn't registering keyboard input. Can anybody figure out why? This in Java, by the way.

Code: [Select]
code

Surely that's not everything. I'm seeing lots of undeclared variables and methods. I'm not seeing any declaration of any kind of GUI components either.
Logged

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #509 on: February 12, 2012, 05:11:03 pm »

I'm very curious, what does it take to make a simple interface for a game, a menu for example? Generally at least. Also what kind of libraries are needed for this?
Logged
This conversation is getting disturbing fast, disturbingly erotic.
Pages: 1 ... 32 33 [34] 35 36 ... 91