This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - nemo
16
« on: August 18, 2011, 12:42:23 pm »
for one, as you said, MainGraphics is an abstract class so you can't make an object from it. secondly, you can't add graphics to a frame because the class Graphics2D is not a type of Component. here's a quick graphics example to get what you want to do:
public class Test extends JPanel{
public Test(){ JFrame frame = new JFrame("test"); frame.getContentPane().add(this); frame.setSize(300, 300); frame.setVisible(true); }
public void paintComponent(Graphics g){ super.paintComponent(g); g.drawLine(5, 5, 10, 10); }
public static void main(String[] args){ new Test(); } }
17
« on: August 02, 2011, 10:12:40 pm »
i've been going slowly [read: turtle swimming in molasses slow] in learnyouahaskell because i don't really know what to program with it. i just use it to solve project euler problems and implement algorithms/data structures for the challenge. i'm at 9. Input and Output, if anyone's curious.
18
« on: August 02, 2011, 03:06:45 pm »
here's my attempt, though my use of pointers is probably pretty ugly since i just used an online tutorial as a reference for that part.
#include <stdio.h>
unsigned long pow(unsigned long base, unsigned long exp) { if(exp == 1) return base; return base * pow(base, exp - 1); }
char *GetString(int stringLength, unsigned long combination) { char* character = malloc(sizeof(char) * 2); *character = combination % 26 + 'a'; *(character + 1) = '\0'; if(stringLength == 1) return character; return strcat(GetString(stringLength - 1, combination / 26), character); }
int main(int argc, int *argv[]) { const int MAX_LEN = 3; int len; unsigned long i; for(len = 1; len <= MAX_LEN; len++) { for(i = 0; i < pow(26, len); i++) { printf("%s\n", GetString(len, i)); } } return 0; }
19
« on: July 19, 2011, 07:27:36 pm »
quick question, what's the advantage of currying in axe? as runer pointed out, it takes up more memory, and in my opinion, looks messier
20
« on: June 23, 2011, 09:42:07 pm »
Can you clarify your question? I thought y-movement is generally independent from x-movement, and since you said walking speed is constant, x = x0 + v0t + .5at2 wouldn't really make much sense.
ok, so i have the variables x, y, and yVel. there's also the constants XVEL, GRAVITY, and JUMP_FORCE. XVEL is how many pixels the character moves right each frame. GRAVITY is how many pixels the character falls each frame (if it can fall). JUMP_FORCE is the initial upward velocity when the user presses space (makes the character jump). i tweaked my engine so that the character jumps at a desire length/height. but now i want to double XVEL, making the character move twice as fast. however, now i need to tweak GRAVITY so that the character falls faster, in order to make sure the length of the jump remains constant. but because i tweaked GRAVITY, now JUMP_FORCE needs to be modified so the height of the jump remains constant as well. however, i don't know how much to modify these constants. and it isn't as simple as doubling GRAVITY and JUMP_FORCE, i already tested that. edit: alright, i think i've found an equation. if XVEL is multiplied by p, JUMP_FORCE is multiplied by p and GRAVITY is multiplied by p^2. right now i'm trying to tweak my engine so i can get some data (e.g. what's GRAVITY and JUMP_FORCE when XVEL is multiplied by 2? multiplied by 3? etc...) and then use a regression to find an equation from that. but i was wondering if anyone knew how to figure out the equation mathematically.
21
« on: June 23, 2011, 09:30:44 pm »
if you've doubled the walking speed, wont just doubelling the other speeds work?
i tried that and it does not work. the height and length of the jump vary still
22
« on: June 23, 2011, 06:27:03 pm »
bump, anyone?
23
« on: June 23, 2011, 06:21:14 pm »
supposedly the benefits of OOP come in on large projects, but overall OOP projects require much more time planning how classes interact with each other. IMO OOP gets in the way when i code. i really only use java over C/C++/functional programming languages because i can't find an easy to install GUI library. so i agree with Qwerty. programs being programmed by 1 person aren't large enough to reap the benefits of OOP, and for larger scale projects i can't say because i've never programmed in a team.
24
« on: June 23, 2011, 09:18:10 am »
this question could really go anywhere dev-related, but since my game's being programmed in java i put it here.
Are there any equations which, given a constant horizontal speed, will give a gravitational constant and an acceleration constant (intial upward velocity for when the character jumps) given that the height and length of the jump must remain constant?
i.e., i've programmed my game using a speed of 3 pixels/frame and tweaked the upward velocity and gravity until i liked the height/length of the character's jump. now i want to be able to have a speed of say 6 pixels/frame and have an equation which calculates the upward velocity and gravity so that the height/length of the jump isn't changed from my 3 pixels/frame speed.
i know that x = x0 + v0t + .5at2, but i am unsure if that can be applied in this case, and if so how.
thanks for the help!
25
« on: June 20, 2011, 04:16:43 pm »
chars work for small ints from -127 - 128 or 0 - 255 no ints go above or below that, or they shouldn't.
you could try declaring your char arrays signed to make sure -1 won't mess them up.
26
« on: June 20, 2011, 04:06:24 pm »
yes, *(array + x + (y * yy)) is the right expression. you should rename your variables for clarity.
also, i just googled that the size of char in c++ is 1 byte, while int is 4 bytes. i think that ashbad is right; you're putting integers into character spaces.
27
« on: June 20, 2011, 03:13:41 pm »
i've never used pointers in C/C++ (the only thing i know is & and * are related) but this code looks kinda weird:
char * tiles; tiles = new char [xx * yy]; // this array will store the image number for each tile char * array = &tiles[0];
are you sure that works? why not just do this?
char * array; array = new char [xx * yy]; // this array will store the image number for each tile
i may be misunderstanding pointers and C++ though but it seems like you have two pointers to the same map.
and again the "*(array + x + (x * y))" in the initializing part needs to be changed to "*(array + x + (x * yy))"
28
« on: June 20, 2011, 02:34:12 pm »
i thought memblock[0] and memblock[1] are for the size? and that code segment starts writing at memblock[2] not memblock[3].
regardless, the code i cited in my first post has an issue, memblock[x * y + 2] and memblock[x * y + 3] are written to when they shouldn't be.
and
*(array + x + (x * y))
should be
*(array + x + (x * yy))
29
« on: June 20, 2011, 02:12:21 pm »
well, for one, this code segment doesn't work:
memblock = new char [size]; memblock[0] = x; memblock[1] = y; for(int i = 0; i<size; i++) { memblock[i+2] = *(array + i); }
it writes over memblock[size] and memblock[size + 1] when i don't think it should. then again i code in Java, not C/C++.
if that doesn't fix anything i'll look over the rest of the code.
edit: to clarify, this is in the SaveFile method
30
« on: June 19, 2011, 07:10:46 pm »
i always do the same thing cooliojazz does for images, although it won't affect the error you're getting scout. i found a good explanation of how displaymodes work. what i would first do is test if isFullScreenSupported, and then do something similar to what's in the example code in the link. if it isn't, i don't have a solution. if it is, use setFullScreenWindow and see if your code works. if it still doesn't work, do the follow somewhere in the Screen class and copy/paste what's printed out: for(DisplayMode dm : vc.getDisplayModes()) System.out.println(dm);
then it pick the DisplayMode printed out that's closest to the one in your code and use it: DisplayMode dm = new DisplayMode(800,600,16,DisplayMode.REFRESH_RATE_UNKNOWN);
|