Sgt. Pepper 0 Light Poster

The whole thing was written in awt, so in order to change it to swing, it seems I'd have to redo certain classes. Also, this professor isn't exactly what you'd call... compitent.

And I take it from what you said he's either messing with the class, or teaching us completely dated information, as it seems that every homework assignment he gives uses a rather old and out of date class.

Sgt. Pepper 0 Light Poster

Hello,
My assignment in class is to write a notepad program in java, using only the .io and .awt extensions (I believe that's what they're called). Now, I've got every part of the program working, except the save and saveAs functions. I've spent roughly 5 hours looking for and trying things that would solve my problem, but have found nothing (This professor doesn't really teach java, he teaches from the glossary, so it's become a learning experience in itself). the code I have so far is taken from the web, and I have modified it a bit to suit my program. I've gotten to the realization that it's not actually saving, and it doesnt know where to save to, and that's where I'm at a loss. How might I get that to change? Code is as follors for the two functions:

       private void doSaveAs() {
           StringBuffer textBuffer = new StringBuffer();
              FileDialog fileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
              String name = fileDialog.getFile();
                fileDialog.setFilenameFilter(new FilenameFilter() {
                    public boolean accept(File dir, String name) {
                        return name.endsWith(".txt");
                    }
                });
                fileDialog.setFile("Untitled.txt");
                fileDialog.setVisible(true);
                System.out.println("File: " + fileDialog.getFile());
                setTitle("JavaEdit: " +name);   // reset frame title
                text.setText(textBuffer.toString());
           }
       private void doSave() {
            FileDialog fileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
            String name = fileDialog.getFile();
            if(name == null)
            {
                doSaveAs();
            }
            else{
                System.out.println("File: " + fileDialog.getFile());
            }
           }

Also, I'm not sure, but I do believe the normal save function brings up the dialog box. How I would I hypothetically have that not happen?

Thanks …

Sgt. Pepper 0 Light Poster

Alright, so what I want to happen, is basically you click the clear button, and it wipes the canvas. After wiping it the previously drawn shape's button should still be enabled.

What actually happens is you click clear, and it selects the clearRect shape, so you would have to go and again select the shape you want to draw.

Sgt. Pepper 0 Light Poster

So, when you draw a shape, and hit the clear button, it de selects any current shape and redraws the background as a clear rectangle. I would like it to keep that shape. Also, the reset button should be the same, save to set the shape to circle.

Sgt. Pepper 0 Light Poster

You click the buttons, and drag and drop on the canvas

Sgt. Pepper 0 Light Poster

DrawCanvas.Java

import java.awt.*;
import java.awt.event.*;

public class DrawCanvas extends Canvas implements MouseListener,
                                                  MouseMotionListener {

    // Constants for shapes
    public static final int CIRCLE = 1;
    public static final int ROUNDED_RECTANGLE = 2;
    public static final int RECTANGLE_3D = 3;
    public static final int LINE = 4;
    public static final int OVAL = 5;
    public static final int SQUARE = 6;
    public static final int CLEAR = 7;

    // Coordinates of points to draw
    private int x1, y1, x2, y2;

    // shape to draw
    private int shape = CIRCLE;
    /**
     * Method to set the shape
     */
    public void setShape(int shape) {
        this.shape = shape;
    }

    // filled color
    private Color filledColor = null;
    /**
     * Method to set filled color
     */
    public void setFilledColor(Color color) {
        filledColor = color;
    }

    /**
     * Constructor
     */
	public DrawCanvas() {
	    addMouseListener(this);
	    addMouseMotionListener(this);
	} // end of constructor

    /**
     * painting the component
     */
    public void paint(Graphics g) {

        // the drawing area
        int x, y, width, height;

        // determine the upper-left corner of bounding rectangle
        x = Math.min(x1, x2);
        y = Math.min(y1, y2);

        // determine the width and height of bounding rectangle
        width = Math.abs(x1 - x2);
        height = Math.abs(y1 - y2);

        if(filledColor != null)
            g.setColor(filledColor);
        switch (shape) {
            case ROUNDED_RECTANGLE :
                if(filledColor == null)
                    g.drawRoundRect(x, y, width, height, width/4, height/4);
                else
                    g.fillRoundRect(x, y, width, height, width/4, height/4);
                break;
            case CIRCLE :
                int diameter = Math.max(width, height);
                if(filledColor == null)
                    g.drawOval(x, y, diameter, diameter);
                else
                    g.fillOval(x, y, diameter, diameter);
                break;
            case RECTANGLE_3D …
Sgt. Pepper 0 Light Poster

Hello, I've got this problem with an intro to Java class. To lay some background down, the professor teaches the 'theory' behind java, and nothing of actual code, so my knowledge is very limited here.

The reason I'm here is I can't discern for the life of me how to clear a java Canvas. I've created shapes on it (rectangles, lines etc). But the goal I seek here is to create a clear button (which will clear the canvas, and let the use create more of the same shapes with the same color) and a reset button(which does the same as clear, but resets to normal). With the reset button, I got everything to reset, but it does not erase.

ex code of that

case OVAL :
            	diameter = Math.max(width, height);
                if(filledColor == null)
                    g.drawOval(x, y, width, height);
                else
                    g.fillOval(x, y, width, height);
                break;

I have no real idea how to erase it. My professor vaguely hinted at clearRect, but I'm at a loss as to how to implement this. Here are the things I've tried from sources all over the internet:

case CLEAR : 
            	//repaint();
            	//g.clearRect(x, y, width, height);
                g.setColor(getBackground());
                g.clearRect(0, 0, width, height);
            	break;

When I do use it, My current shape selection disappears. And when used with reset, the shape stays, but reverts to the standard shape when the program starts. Is there another way, that would just erase the canvas?

Thanks in advance.

Sgt. Pepper 0 Light Poster

So to read it from a file, would I overload the << operator? How would I go about doing that for a class, just have it get each stat through get functions?

Sgt. Pepper 0 Light Poster

Could you go into more detail about what you're looking to do? Operator overloading should work similarly to any other function or method, regardless of whether it is divided into multiple files or not. Or were you referring to data files?

I meant as in having multiple files for the program. What I've been taught is to use friend functions to do operator overloading, but we havent gone over how they divide amongst different files

Sgt. Pepper 0 Light Poster

checkers, chess, all card games, txt based fighting games

Sgt. Pepper 0 Light Poster

How would I go about operator overloading when I have multiple files?

Sgt. Pepper 0 Light Poster

Thanks again! You have been absolutely excellent in helping me with this. That really did clean the program up a lot, too.

Sgt. Pepper 0 Light Poster

So, here I am again, with my mass of code, albeit with more progress.
It's still got a long way to go, and I'm still not that good at coding, but man oh man have I learned a lot through this game.
I come with a few more questions than last time.

So to get to my first problem, You have to go to Select Character -> Create Character -> Enter Name -> Use all skill points. The problem is that it doesn't use all of the skill points. Any suggestions? (This is the setStats function, by the way)

And then another problem with that, is I can't really come up with a good way to end that loop - I was thinking maybe a finish selection(but I couldn't figure a way to implement that). Anything on this one either?

Also, I'm curious about how other people think I should go about adding spells/items to Character's class.


Another topic I'm curious of is how would I write/read creatures to/from files(say for saved characters).

The last one is I can't think of a good way other than an if statement per character in order to make them the character the player will use (unless I overload my select function).


The full program:

//RPG Game
#include <iostream>
#include <windows.h>
#include <string>
#include <conio.h>
#include <vector>
#include <dos.h>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <fstream>
using namespace std;
HANDLE …
Sgt. Pepper 0 Light Poster

Alright, so i fixed my main problem.
The issue was that I didnt completely destroy the second row, which i fixed with a simple resize function. So then I had the issue of my controls inverting, so i inverted them(again). but I'm still stuck on the problem of converting a integer array into strings, then adding it to the end of a string.

Sgt. Pepper 0 Light Poster

With the border issue, when I tried it, it kept throwing errors. I don't remember what they were, but now it seems to work. I also fixed the seeding. Thank you very much. Is there any way to modify the original post so it doesnt draw further attention?

Sgt. Pepper 0 Light Poster

So, Ive created a UI in console. No questions as to why. But anyways, It used to be just a simple array, but I decided to make it with vectors both to improve my skill with them, and to make its size dynamic.

Dont mind the mess of code here.

//RPG Game
#include <iostream>
#include <windows.h>
#include <string>
#include <conio.h>
#include <vector>
#include <dos.h>
#include <ctime>
#include <iomanip>
#include <fstream>
using namespace std;
HANDLE  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
static string selection;

void hL(string s){
	int highLight = 240;
	HANDLE  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, highLight);
	cout << s << setw(10);
	int nonHighLight = 15;
	SetConsoleTextAttribute(hConsole, nonHighLight);
}
void nHL(string s){
	int nonHighLight = 15;
	SetConsoleTextAttribute(hConsole, nonHighLight);
	cout << s << setw(10);
}
void bS(){
	int blankSpace = 0;
	SetConsoleTextAttribute(hConsole, blankSpace);
	cout <<	"		" << setw(5);
	SetConsoleTextAttribute(hConsole, 15);
}
void borderDown(){ //Stupid formatting due to angry compiler gods
	const char o = 209;
	cout << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o
		<< o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o << o
		<< o << o << o << o << o << o << o << o << o << o << o …
Sgt. Pepper 0 Light Poster

I seem to have killed the problem just tinkering, thanks anyways though!

Sgt. Pepper 0 Light Poster

I recently left my laptop on all day without touching it at a friends house, and when I came back to it, I could not click on any windows. So doing ctrl-shft-esc, I brough up the task manager, and the only way I could navigate through it was by keyboard, both my wireless and built in mouses not working. I restarted explorer and such, and it worked for a little bit, but then it went back to not letting me click on windows, and whenever I tried to click on them, it showed them unhighlighted, like some giant invisible window was open in front of them that I was clicking on (presumably some windows explorer monster). Restarts don't work, as the problem comes up every time I reboot windows. And it goes away after killing windows explorer enough times. Any ideas as to what this is? My laptop is fairly new, running Windows Vista Home 64 sp2.

Thanks for any input!

Sgt. Pepper 0 Light Poster

thanks narue!

Sgt. Pepper 0 Light Poster

Although it would be nice, headhunting isn't a job I can pick for this paper.

Sgt. Pepper 0 Light Poster

erm... about that... Skills*

Sgt. Pepper 0 Light Poster

Hello,
To whomever is reading this and has a job as a Programmer or anyone that has a degree in computer science, It'd be much appreciated if you could answer some questions for an interview required for my research paper for my high school final in English. You don't have to answer all of the questions and the answers don't have to be long, I just need some feedback
Please state your job, position, company, etc.
The questions are

-What is your job like? A typical day? What do you do? What are the duties/functions/responsibilities of you job? What kind of problems do you deal with? What kinds of decisions do you make? What percent of your time is spend doing what? How does the time use vary? Are there busy and slow times or is the work activity fairly constant?

-How did this type of work interest you and how did you get started?

-How did you get your job? What jobs and experiences have led you to your present position?

-Can you suggest some ways a student could obtain this necessary experience?

-What are the most important personal satisfactions and dissatisfactions connected with your occupation? What part of this job do you personally find most satisfying? Most challenging? What do you like and not like about working in this industry?

-What things did you do before you entered this occupation? Which have been most helpful? What other jobs can …

Sgt. Pepper 0 Light Poster

hey, im just a senior in high school, and im one of the best people in the school with computers, i was just wonder if anyone knows what i should go to college for if i want to use computers outside (hahahaha oxymoron) or doing visual graphics or something of that sort


ty

Sgt. Pepper 0 Light Poster

My recommendation: C++ all the way

Plus, C++ is the most respectable to most people

Thank you, thats all I wanted to hear!

Sgt. Pepper 0 Light Poster

Ok, now it works, i just started a new project, didnt even have to include the test file in it, but anyways thank you guys

also, how do you put the code in the special formated text thing on this forum?

Sgt. Pepper 0 Light Poster

// Test file

include <iostream>
using namespace std;
int main()
{
    cout << "yarg!" << end1;
return 0;
}

No errors, yet the run, build, and other buttons of that sort are grayed and unusable.

Sgt. Pepper 0 Light Poster

Ok, no matter what compiler i use, i can never find a compiler that will build/compile/run a single file like the one I have used in my school.

i got Code::Blocks to compile my test file

the code is short:
// Test file

include <iostream>
int main()
{
    cout << "yarg!" end1;
return 0;
}

can anyone please help me? the book I have starts off with single file programs and this is a major mountain that I keep stopping at whenever I start to read this book.

Thank You :cool:

Sgt. Pepper 0 Light Poster

OK, hes a list of the things I've used:

Premade Engines (I dont know what the program thing is called)
Torque Game Engine
3d Game Studio

3D Editing Programs
GMax
3DSMax
a little Milkshape

Porgramming
starting C++

2d Graphics
Correl
Photoshop

Game Making Programs
RPG Maker2k

Game Editing Programs
TES Construction Set (TES: Morrowind and Oblivion editor)
Renegade programs (gmax and such)
used to make maps and such in Red Alert 2 and Tiberian Sun

OK now here is my question: I'm interested in creating a game, but everyhwere I go, everyone says to either use a premade engine or modify another. But for me, that is way to expensive. I have the game ideas so thats no problem, I just have no way of outputting them. I was thinking of making simpler games first and working my way up to the harder ones.

Can anyone point me in the right direction? Will it be too hard for one person to make a game engine (and what work will it require)? And which program should i learn extensively first?

Thank You

Sgt. Pepper 0 Light Poster

I'd make half of the US a preserve, buy a really nice RV, and a really nice computer with a wireless internet card, a really nice camera, and an old WWII M1 Grand and just travel around the preserve livin off the land and doing computer stuff at the same time

Sgt. Pepper 0 Light Poster

Thank You

Sgt. Pepper 0 Light Poster

I bought the book C++ Primer Plus http://www.amazon.com/C%2B%2B-Primer-Plus-Stephen-Prata/dp/0672326973/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1202680271&sr=8-1 because i plan on learning the C++ language, but i can't really understand what it is trying to say when it is suggesting compilers. Can anyone give their feedback on the best compilers for beginners?

And also, C++ is the best place to start for a Game Programmer right?