When my process is "lagging", if I move the mouse, the "USER Objects" count in task manager can spike. The faster I move the mouse, the higher it goes - up to 230. After alt+tabbing in and out a couple times, it will stay at 14-17, no matter how fast I move the mouse.
I'm using raw input from the mouse, and yes, I call DefWindowProc.
[editline]4th January 2011[/editline]
SON OF A BITCH it was the debugger the whole time
I thought I was grossly incompetent for...three hours there. At least my Windows main.cpp is a lot cleaner now.
[QUOTE=Wyzard;27183148]Can you change the blending mode so that it does what Photoshop would call a "multiply" rather than using an alpha channel for opacity? That way, a white pixel in the "night layer" would leave the underlying color unchanged (multiplying by 100%), a black pixel in the "night layer" would result in black onscreen (multiplying by 0%), and intermediate shades would darken the image proportionally.
If you do that, your "night layer" can change from being black with 40% alpha to just 40% gray with no need for an alpha channel. Then, each frame you can render the flame into the night layer using blurry white blobs instead of flame sprites as the particles, and you'll get an area around the flame where the ground doesn't get darkened as much, so it looks like illumination from the fire.[/QUOTE]
I think i see what you mean, problem is atm its just one big texture so i cant edit any of it and as the player is going to be moving i need the lighting to be dynamic, but il look into your way
I of course know that im going to have to rewrite the way darkness is affected.
Going to look see if theres any simple solutions using HLSL
Ok i might need some help.
I am doing a thread in java for a game i am making. Just a simple half text half menu based game with a basic gui.
Anyway so the problem i am having is that the thread only does 32 loops then stops working. No errors just stops.
My first thought was that the thread errors but it doesn't throw the exception.
My only other thought is that for some reason it just finishes the loop.
Anyway here is the code. for the thread running function in the thread object.
[code]
public void run() //This determines when customers enter the store and the processes of them.
{
try
{
int ab = 0;
while(true)
{
NewCustomers();
ab++;
Main.Debug("Customer created: "+ab);
OManager.Ply.incDay();
Thread.sleep(Player.GameSpeedModifier);
}
}
catch(Exception e)
{
Main.Error("CustomerManager","ERROR IN THREAD. THREAD CLOSED!");
}
}
[/code]
Here is how i created them.
.
[code]
public class ThreadManager
{
ObjectManager OManager;
CustomerManager CManager;
Thread CustomerThread;
public ThreadManager(ObjectManager omanager)
{
OManager = omanager;
CManager = new CustomerManager(omanager);
CustomerThread = new Thread(CManager);
CustomerThread.start();
}
}
[/code]
It would appreciate it if someone could help.
Hi i found this [url]http://www.sgtconker.com/2009/10/simply-rendertargetsplaceholder/[/url]
that looks easy to do and should work but, it doesnt explain how to create the triangle
[editline]4th January 2011[/editline]
Got it working :buddy:
[img_thumb]http://img816.imageshack.us/img816/5994/untitlebd.png[/img_thumb]
[QUOTE=stinkfire;27191926]public class ThreadManager[/QUOTE]
Are you making a blocking thread join call in the main process/thread?
[editline]4 January 2011[/editline]
I see it looks like its supposed to run indefinitely. Is the main thread terminating before the child threads finish? Might be worth making a blocking call just to see what happens, even if the main thread runs indefinitely.
How do I make a regular expression that matches a specific string, but there can be a decimal point between any of the characters? (Only one decimal point in the string, but it's not that important to check for that.)
[QUOTE=shill le 2nd;27197841]How do I make a regular expression that matches a specific string, but there can be a decimal point between any of the characters? (Only one decimal point in the string, but it's not that important to check for that.)[/QUOTE]
[code](s\.?o\.?m\.?e\.?s\.?t\.?r\.?i\.?n\.?g)[/code]
But seriously, please, don't use this :downsgun:
[editline]4th January 2011[/editline]
How about just removing all decimal points and match the regex with that?
So how do I cutout part of an image in SFML? Like an irregular circle or something.
[QUOTE=bootv2;27199294]editing the image pixel by pixel into the form just setting all the edited pixels to 255 alpha would work I guess, would just be a lot of work. but you could write a function for each form you want to get out, and you could just input how big the thing is you want to output. this way it's easily recoverable. just some work to set the system up.
if this doesn't sound very logical, please excuse me. I'm tired as hell right now.[/QUOTE]
That sound's pretty CPU intensive. Is there any way to mask without editing it?
[QUOTE=bootv2;27199453]no way I'm aware of. but you could do it when your game is still starting if that's possible. so you won't experience any in-game lagg. just some latency in starting the program.[/QUOTE]
No I am trying to make it so that when you access a secret area, a circle appears around you that would like make the areas it touches see through (basically a circle gets cut out around you). I thought of just putting a white circle, but I want to keep the background intact. Is there a way to make irregular circles in SFML? Because then I can make one and use the background image to overlay the tiles.
[QUOTE=bootv2;27199680]I understand your point. coudn't you just take a certain perimeter around the center of your screen(thus where the character is walking) and only drawing that. would even be less intensive than normally, but it wouldn't be a good circle, just a circle of squares made of your tiles. This could be sufficient until you've found a better solution. because cutting the sprites of the tiles in parts to create a excact circle probably would be too cpu intensive for your program too.[/QUOTE]
The tiles are 40 by 40 and the characters is 40 by 60 so yeah. Wouldn't look good. I'll look for a solution for now.
Can I transfer a transparency mask from one image to another? So I can make a circle made out of the background and just overlay that.
Implemented a temporary solution for draw order of translucent...things, and added one pixel padding to my text rasterization method so you don't get the "bleeding pixels" from smoothed textures. I'm so glad I didn't need to touch my texture allocation scheme!
[url]http://eagle.undo.it:8083/img/kintel_14.png[/url]
Isn't it awesome when you think you might have to re-do a dependency to upgrade a method, and it turns out to be contained only in logically relevant classes?
(Easier to debug the algorithm for drawing upside-down. Flipping it is trivial once it works perfectly, but this image looks more interesting :v:)
Also, finally settled on an entity hierarchy so that I could network it easily. This also proved invaluable when storing references to entities hit by traces.
[editline]4 January 2011[/editline]
Whoops, wrong thread. Don't let me derail.
In Java if you have a set of arrays like this:
anArray[0] = 100;
anArray[1] = 250;
anArray[2] = 300;
Is it possible to assign a variable the value of a random array? Such as...
int number1 = anArray[*random array here*];
As long as the random number isnt out of scope yes
in other words if you have an array with 200 values you cant assign array value 201
[QUOTE=W00tbeer1;27200676]In Java if you have a set of arrays like this:
anArray[0] = 100;
anArray[1] = 250;
anArray[2] = 300;
Is it possible to assign a variable the value of a random array? Such as...
int number1 = anArray[*random array here*];[/QUOTE]
In contrary to what Richy19 is saying, this is [b]not[/b] possible. Many people have investigated this problem over the past few years, but a solution to this problem has not been observed yet.
[QUOTE=LiquidLight;27200821]In contrary to what Richy19 is saying, this is [b]not[/b] possible. Many people have investigated this problem over the past few years, but a solution to this problem has not been observed yet.[/QUOTE]
Really? I'm trying to figure out a way to allow a variable to be assigned the value of a random constant.
This was one of the only ways I could think of it working, but I'm pretty sure there's a way.
For example, you have these variables (which shall be constants)
int NUM1 = 50;
int NUM2 = 100;
int NUM3 = 150;
Now I want these variables to be assigned the value of one of the random constants
int num1 = (either NUM1, NUM2, or NUM3); (Lets say that NUM3 is chosen randomly here)
int num2 = (either NUM1 or NUM2); (Lets say that NUM2 is chosen randomly here)
int num3 = NUM1;
Do you understand what I'm trying to do?
[QUOTE=LiquidLight;27200821]In contrary to what Richy19 is saying, this is [b]not[/b] possible. Many people have investigated this problem over the past few years, but a solution to this problem has not been observed yet.[/QUOTE]
Funny
[code]
public static void main(String[] args) {
int hello[] = new int[100];
int random;
Random r = new Random();
for (int i = 0; i < 100; i++) {
hello[i] = r.nextInt(200);
}
for (int i = 0; i < 10; i++) {
random = r.nextInt(99);
System.out.println(hello[random]);
}
}
[/code]
Seems to work fine for me
[QUOTE=Wig Wam;27178199]How do I pass an int value e.g int bullet = 1; into another class in Java?
Bit more of an explination.
Got 4 if statements - When one of them is chosen, it will make bullet equal either 1,2,3 or 4.
The program then changes screens and moves to another, seperate class. This class needs to use the value of bullet to determine a few simple things.
How do I get the value of bullet from one class into another ?[/QUOTE]
I'm a little surprised that you know how to make classes and yet you don't know how to do this. One of the first things most people learn about classes in Java is how to write "get" and "set" methods for accessing class variables.
Make a public method in your first class that returns the value of bullet. Use that function where it's needed in your second class.
[QUOTE=Wig Wam;27178199]How do I pass an int value e.g int bullet = 1; into another class in Java?
Bit more of an explination.
Got 4 if statements - When one of them is chosen, it will make bullet equal either 1,2,3 or 4.
The program then changes screens and moves to another, seperate class. This class needs to use the value of bullet to determine a few simple things.
How do I get the value of bullet from one class into another ?[/QUOTE]
Here is an example of accessor and mutator methods.
They change values in the object bullet and also print them out.
[code]
public class test
{
public static void main(String[] args)
{
bullet MyBullet = new bullet("50.cal",1000);
//Print out the name and damage of the bullet.
System.out.println("BULLET NAME: "+MyBullet.getName());
System.out.println("BULLET DAMAGE: "+MyBullet.getDamage());
//Change the values of the bullet.
MyBullet.setName("5mm");
MyBullet.setDamage(1);
//Print out the name and damage of the bullet.
System.out.println("BULLET NAME: "+MyBullet.getName());
System.out.println("BULLET DAMAGE: "+MyBullet.getDamage());
}
}
class bullet
{
//Variables of the bullet.
String Name;
int Damage;
//Constructor method. Used when the bullet is created.
public bullet(String name,int damage)
{
Name = name;
Damage = damage;
}
//Accessor methods. Get something out of the object.
public String getName()
{
return Name;
}
public int getDamage()
{
return Damage;
}
//Mutator methods. Change somethign in the object.
public void setName(String name)
{
Name = name;
}
public void setDamage(int dam)
{
Damage = dam;
}
}
[/code]
I'm working on a 2D game in Java, and I'm looking to get shooting to work, and I've found a way which requires me to draw my character in class, but I'm not sure how to do this. What I'm asking, essentially is: is it possible to draw an image in a Java class file, or is there a better way to do shooting?
[Will edit with code, need to fix it up, left my test code at home.]
As promised, here is the code I am using to work on this.
[code]import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.sound.sampled.*;
import java.net.*;
public class KeyboardRecognition extends Applet implements Runnable {
int x_pos = 50, y_pos = 100, x_speed = 0,
y_speed = 0, radius = 22, appletsize_x = 638,
appletsize_y = 478;
double rotatenum, rotatenum2;
private Image dbImage;
private Graphics dbg;
Image defiant;
int keys[];
public void init() {
keys = new int[256];
Arrays.fill(keys,0); // 0 = key is up
enableEvents(AWTEvent.KEY_EVENT_MASK);
//background color
setBackground(Color.black);
defiant = getImage(getDocumentBase(),"defiant.gif");
}
public void start () {
Thread th = new Thread (this);
th.start();
}
public void processKeyEvent(KeyEvent e) {
// the 0xff below binds the key code to below 256
int key = (e.getKeyCode()&0xff);
if (e.getID() == KeyEvent.KEY_PRESSED) {
keys[key] = 1; // 1 = key is down
} else if (e.getID() == KeyEvent.KEY_RELEASED){
keys[key] = 0; // 0 = key is up
}
}
public void run () {
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
while (true) {
x_speed = 0;
y_speed = 0;
if(keys[65] == 1) { // a
x_speed =-2;
rotatenum = -1.57079633;
}
if(keys[83] == 1) { // s
y_speed =+2;
rotatenum = -3.14159265;
}
if(keys[68] == 1) { // d
x_speed =+2;
rotatenum = 1.57079633;
}
if(keys[87] == 1) { // w
y_speed =-2;
rotatenum = 0;
}
if((keys[65] == 1) && (keys[83] == 1)) { // a and s
y_speed =+2;
x_speed =-2;
rotatenum = 3.9269907;
}
if((keys[65] == 1) && (keys[87] == 1)) { // a and w
y_speed =-2;
x_speed =-2;
rotatenum = -0.7853982;
}
if((keys[68] == 1) && (keys[83] == 1)) { // d and s
y_speed =+2;
x_speed =+2;
rotatenum = -3.9269907;
}
if((keys[68] == 1) && (keys[87] == 1)) { // d and w
y_speed =-2;
x_speed =+2;
rotatenum = 0.7853982;
}
//Special for the defiant
if((keys[32] ==1) && (keys[65] ==1)) { // spacebar and a
x_speed = -5;
}
if((keys[32] ==1) && (keys[68] ==1)) { // spacebar and d
x_speed = +5;
}
if((keys[32] ==1) && (keys[83]==1)) { // spacebar and s
y_speed = +5;
}
if((keys[32] ==1) && (keys[87]==1)) { // spacebar and w
y_speed = -5;
}
//Shooting for the defiant
if(keys[71] == 1) { //g
//shooting needs to go here
}
if (x_pos > appletsize_x - radius) {
x_speed = -1;
} else if (x_pos < radius) {
x_speed = +1;
}
x_pos += x_speed;
if (y_pos > appletsize_y - radius) {
y_speed = -1;
} else if (y_pos < radius) {
y_speed = +1;
}
y_pos += y_speed;
repaint();
//speed of moving circle and square
try {
Thread.sleep(2); // you may need to adjust this depending on your pc's speed
} catch (InterruptedException ex) {}
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}
public void update (Graphics g) {
if (dbImage == null) {
dbImage = createImage (this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics ();
}
dbg.setColor (getBackground ());
dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
dbg.setColor (getForeground());
paint (dbg);
g.drawImage (dbImage, 0, 0, this);
}
//paints the applet background and ships on top
public void paint (Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.rotate(rotatenum, x_pos, y_pos);
g2.drawImage(defiant, x_pos - radius, y_pos - radius, 2 * radius, 2 * radius, this);
g2.rotate(-rotatenum, x_pos, y_pos);
}
}
[/code]
[editline]6th January 2011[/editline]
To have this run properly, you should download this image and rename it to "defiant.GIF".
[img]http://i.imgur.com/Q38ip.gif[/img]
Any ideas at all?
Ya'know what I need help with? I need help to know where to go to learn Java. Would I just be better off with a book?
I've never read them, although these look extremely complete: [url]http://www.thenewboston.com/?cat=36&pOpen=tutorial[/url]
[QUOTE=yakahughes;27240740]I've never read them, although these look extremely complete: [url]http://www.thenewboston.com/?cat=36&pOpen=tutorial[/url][/QUOTE]
Oh, a series of video tutorials all collected on a website. Perfect, thank you :D
[QUOTE=The Great Ghast;27240829]Oh, a series of video tutorials all collected on a website. Perfect, thank you :D[/QUOTE]
That said, don't learn Java, learn C++.
[QUOTE=yakahughes;27240740]I've never read them, although these look extremely complete: [url]http://www.thenewboston.com/?cat=36&pOpen=tutorial[/url][/QUOTE]
I love you
[editline]6th January 2011[/editline]
[QUOTE=bootv2;27241249]if he wants to learn java let him, Java may be slow but it sure as hell is easier than c++. maybe he will learn c++ in the end when he's got a basic understanding of the syntax and what programming is all about.[/QUOTE]
He's right. My friend, who claims to have started programming when he was 7, told me C++ is hard to do if your just starting, just following what he says.
[QUOTE=bootv2;27241249]but it sure as hell is easier than c++[/QUOTE]
That's exactly why he should learn C++ first.
[editline]6th January 2011[/editline]
You should learn long division before learning to do it on a calculator.
[QUOTE=bootv2;27241826]no, you should understand before you do. java is to learn how to understand the basics of programming. then do c++ to learn how to use this basics and to let your knowledge grow. personally I started at c++ it was a rough start and up to today it's harder than it would've been if i'd have done another language to understand the basics first.
tl;dr learning java first is a smart step, starting out with c++ will cost you much more time to "master" the programming language.(I know you can't ever really master a language. it's just as a manner of speaking.)[/QUOTE]
I hear that the source code for minecraft is terrible. Anyone wanna explain to me?
[QUOTE=bootv2;27242411]yeah, can't deny that's terrible. but that's the fault of notch. not of the language. I could use the best programming language and write the worst code for it. it's just a manner of how smart you'll use the language. so don't bother if someone badly programs something in a language you want to use.
tl;dr 1 program written in java could be a lot cleaner and faster than in c++. it's just about how it's programmed.(except that java is slow because it's JITted, but since it's just a step to c++ you shouldn't bother with that)[/QUOTE]
But why is it bad? The game is functional.
Sorry, you need to Log In to post a reply to this thread.