Show Posts
|
|
Pages: [1]
|
|
1
|
Discussions / General Discussions / Re: Is Java Missing its Window of Opportunity with Gaming?
|
on: 2013-01-08 07:07:56
|
|
The real downside for Java to me is the lack of support for accelerated graphics on the Mac platform. Apple has a terrible JVM, and even though it mostly works, you won't be doing anything silky smooth if you stay native to Java (no JNI). I went ahead and wrote a bunch of C++ wrappers for all of the Java objects I use just to future proof.
My friend who does graphics and design on our project uses a Mac, and while the editors and engine works, it works like shit. Until we have really great JVMs on all platforms, we're f**ked. Sorry, but it's true. At least with something that compiles to machine code, you're solid.
I see Java as a development platform, but these days, with as many platforms as there are, any language you write in might as well be pseudo code. I plan on releasing in the Lingua Franca for any given platform, which is probably some variant of C.
Antiharpist
|
|
|
|
|
2
|
Game Development / Game Mechanics / Re: Rotation Based Collision Detection
|
on: 2012-04-25 05:46:43
|
You could always rotate the 4 corners of each tile in the opposite rotation of the player and see if the rotated points intersect with the non rotated player rectangle, then also check if any of the corners of the rotated player rectangle intersect with the non-rotated tile rectangle. It's expensive, and not very clever, but I did something like that when messing with rotational based collisions and it worked for me. I've never used Slick, but would assume it has a rectangle/polygon object you can probably use to wrap up your coordinates for the collision checks. If not, here's an inelegant one I wrote when I was playing around with doing rotated collisions in a non-clever way. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| CollRect tile_rect = new CollRect(tile_x, tile_y, tile_width, tile_height); CollRect player_rect = new CollRect(player_x, player_y, player_width, player_height);
player_rect.setDegrees(player_rotation_degrees); boolean collision = player_rect.dumbRotateIntersection(tile_rect);
public class CollRect { public double x, y; public double x2, y2; public double width; public double height; public double mid_x; public double mid_y; public double degrees=0;
public CollPoint2D[] rect_points; private CollRect() {} public CollRect(double x, double y, double width, double height) { this.width = width; this.height = height; this.x = x; this.y = y; x2 = x+width-1; y2 = y+height-1; mid_x = x+(width/2); mid_y = y+(height/2); rect_points = new CollPoint2D[4]; resetPoints();
} public void resetPoints() { rect_points[0] = new CollPoint2D(x,y); rect_points[1] = new CollPoint2D(x2,y); rect_points[2] = new CollPoint2D(x2,y2); rect_points[3] = new CollPoint2D(x,y2); } public void setDegrees(double degrees) { this.degrees = degrees; } public boolean dumbRotateIntersection(CollRect cr2) { if (rotatedIntersect(cr2,this)) { return true; } if (rotatedIntersect(this,cr2)) { return true; }
return false; } private static boolean rotatedIntersect(CollRect cr1, CollRect cr2) { cr1.resetPoints(); cr2.resetPoints();
cr2.rotatePoints(cr2.degrees);
cr2.rotatePoints(-cr1.degrees,cr1.mid_x,cr1.mid_y);
double cx = cr1.rect_points[0].x; double cy = cr1.rect_points[0].y; double cx2 = cr1.rect_points[2].x; double cy2 = cr1.rect_points[2].y;
for (int i=0;i<4;i++) { CollPoint2D p = cr2.rect_points[i]; if (p.x>=cx&&p.x<=cx2&& p.y>=cy&&p.y <=cy2) { return true; } } return false; } public void rotatePoints(double angle) { rotatePoints(angle,mid_x,mid_y); } public void rotatePoints(double angle, double mid_x, double mid_y) { double radians = Math.toRadians(angle); double sin = Math.sin(radians); double cos = Math.cos(radians); double new_x; double new_y; for (int i=0;i<4;i++) { new_x = (rect_points[i].x-mid_x)*cos-(rect_points[i].y-mid_y)*sin+mid_x; new_y = (rect_points[i].x-mid_x)*sin+(rect_points[i].y-mid_y)*cos+mid_y; rect_points[i].x = (int) Math.round(new_x); rect_points[i].y = (int) Math.round(new_y); } } public boolean intersects(CollRect cr2) { CollRect cr = this; if (((cr.x>=cr2.x&&cr.x<=cr2.x2)||(cr2.x>=cr.x&&cr2.x<=cr.x2))&& ((cr.y>=cr2.y&&cr.y<=cr2.y2)||(cr2.y>=cr.y&&cr2.y<=cr.y2))) { return true; } return false; } public CollRect intersection(CollRect cr) { CollRect ir = new CollRect(); if (!intersects(cr)) {return ir;} if (cr.x>=x) { ir.x = cr.x; } else { ir.x = x; } if (cr.x2<=x2) { ir.x2 = cr.x2; } else { ir.x2 = x2; } if (cr.y>=y) { ir.y = cr.y; } else { ir.y = y; } if (cr.y2<=y2) { ir.y2 = cr.y2; } else { ir.y2 = y2; } ir.width = ir.x2-ir.x; ir.height = ir.y2-ir.y; return ir; } }
public class CollPoint2D { public double x; public double y; public CollPoint2D(double x, double y) { this.x=x; this.y=y; } public double magnitude() { return Math.sqrt((x*x)+(y*y)); } public void normalize() { double mag = magnitude(); x = x / mag; y = y / mag; } public double dotProduct(CollPoint2D c2) { return ((x*c2.x)+(y*c2.y)); } } |
|
|
|
|
|
3
|
Game Development / Game Mechanics / Re: Stopping from a jump
|
on: 2012-03-28 04:46:55
|
|
My first suggestion would be to create separate variables for your actions. There are many ways to do it, and you could go elegant and use bit-masks and enumerations (static finals) so that your _status variable could contain many statuses at the same time. You seem to have a jumpAnimator object, so I'm guessing you may just keep your variables in there. Since games are time/frame based, you'll probably want to allow impulse for a certain amount of time, and after that, you could switch into fall or no-collision mode. You can end fall mode when a collision occurs. You could stop your jumps on collisions, but for certain collision types you may not want that behavior, say if you jump through a collectible object.
Jumping can require a lot of checking. In games like Super Mario Bros. you jump higher based on how long you hold down the button, and if you end up hitting the ground while still having the button held down, you need to account for that too so the player doesn't repeatedly jump. If the player is in the air you don't want them to jump again on repeated button presses unless you allow a double jump, or are in water and swimming.
You should have a maximum impulse that you allow, and if you reach that, the jump is over until the button is let go and it is established your are on the ground again. If you collide with an object of the right type, the jump is over. I keep a variable called jump_counter to know how many frames in I am so I can keep track of the impulse. At first you might not even want to distinguish between top and bottom collisions. In the end the world just needs to work, and that can be very difficult.
The best advice I could give is to spend the time and figure out why it doesn't work. It isn't particularly helpful advice, but game programming can be done in wildly different ways, and as long as it works it is right. You should view yourself as the guru, because ultimately you will be providing most of the answers.
|
|
|
|
|
4
|
Game Development / Game Mechanics / Re: Scaling a 2D game ?
|
on: 2011-11-06 07:31:08
|
Fake Scan Lines: We Make Things Look Worse (tm)
WHY?! Haha, I thought I'd get that. For old games though, the limitations of delivery were definitely there, and did contribute. I tried playing Castlevania - Symphony of the Night on XBOX 360, and had to quit early, not only for the overly compressed audio, but because graphically it looked like garbage, so I fired it up on my old PSX on a CRT. Some people like the noise. I like the noise; I like listening to LPs. To each their own. I was just providing options. If you want to evoke the same mood of what you would see back when people used CRTs, scanlines can help. In the US lots of hipsters like to drink PBR, not because it is good, but because they are douche bags. I'm not scoring myself any points here. I agree, for the most part, scanlines look like ass; so does playing Kid Icarus or Symphony of the Night on anything other than a CRT.
|
|
|
|
|
5
|
Game Development / Game Mechanics / Re: Scaling a 2D game ?
|
on: 2011-11-06 06:08:09
|
I've been doing a 2D game with NES palette and resolution. I blit to a 256x240 canvas for all operations, and just use bilinear interpolation and fake scanlines to make it look presentable. I know a lot of people may not like the look of scanlines, but to me that's what gave those old games a distinct look. We preserve the 4x3 aspect ratio, and even the NES uneven 256x224 (NTSC) look. If you have a newer Java, and a decent graphics card, you can fake it pretty well. This isn't fancy, but it's simple, and what we used: Upscale 4x3 Nintendo style graphics to whatever native resolution.
1 2 3 4 5 6 7
| Graphics2D g = (Graphics2D) some_graphics_object;
int nes_height=240; nes_width = (int)(((float)screen_width/((float)screen_height/(float)240))*.8); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); int nes_remainder = (int)((float) screen_width-(float)screen_width*(float)256/(float)nes_width)/2; g.drawImage(nesImage, nes_remainder,0,screen_width-nes_remainder,screen_height,0,0,256,240,this); |
Fake scanlines1 2 3 4 5 6 7 8 9 10
| int scanline_count = 224; int s_size = screen_height/scanline_count; g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); g.setColor(new Color(0,0,0)); for (int i=0;i<screen_height;i++) { if (i%s_size==0) { g.drawLine(0,i,screen_width,i); } } |
Before After
|
|
|
|
|
6
|
Game Development / Game Mechanics / Re: 2D rotational velocity
|
on: 2011-10-21 04:32:12
|
|
I've talked with my partner on the game, and we've decided to keep it simple. Our whole goal is to make a C64/NES style game that would make us proud at age 10. We are very good at what we know, and it feels like a good idea to try to learn some new stuff to push it further, but in the end, the 10 year old only cares about the well done bits. If anything, I'll use the rotated code simply for aesthetics, so we can do slopes that aren't just boring 45 degree simple pixel things.
Thanks for all of the input, but we are in the finishing run, having a mostly playable game with good old-school mechanics and playability. I'm not doing anything epic, and I'm not in it for fame or money. Sometimes you do things from your heart, and if anything we'll put out a pretty, nice sounding game out that only we appreciate; So be it. I'm happy with the where we are, and that's coming from the unpretentious kid inside. It's better to do something simple and highly polished than releasing an unfinished learning experiment. I'm not giving up, but the project/game is my focus, and sometimes limitations are great amigos. I'll save the newly acquired things I'm not very good at for another project.
|
|
|
|
|
7
|
Game Development / Game Mechanics / Re: 2D rotational velocity
|
on: 2011-10-13 08:39:11
|
|
Thanks Roquen, I'll see if that book is something I could digest. Even if I can't, I'll be very persuaded to take classes so that I can have a better understanding. Collision handling/response has definitely been the most challenging thing for me with the project I am working on. I also have a book on 3D math, but I always feel humbled and really intimidated. I guess it might be a good thing to do some rote learning, even if I don't desire it.
Delt0r, I just drew stuff on the back of an envelope in initial planning, and realized that I had to check both rectangles to see if coordinates/vertices of either intersect with the other rectangle. I don't know if that's what you mean about different sized rectangles, but in testing I tried many different sizes and it all worked. SAT is nicer in that earlier escapes are possible, but then there is also the benefit that if I test every point, I can record all collision points (at least corners) for special handling later on. Everything I'll want to test is definitely convex.
The hardest part isn't the detection; it's the response. I was thinking if I want to make it so that gravity actually pulls down a dangling half of a block pushed over a ledge, I have to know where the collision points are in order to influence the rotational velocity. I've faked it, but it just isn't right. Is it typical to record points, or subdivide a rectangle in order to know how to influence rotation velocity? I guess I can always try. If it works, then it's not the wrong way.
Antiharpist
|
|
|
|
|
8
|
Game Development / Game Mechanics / 2D rotational velocity
|
on: 2011-10-12 05:30:04
|
|
I'm an vacation/holiday this week, and got 2D rotated rectangle collision detection working. I'm not smart enough for Separating Axis Theorem right now, so just leave the rotation on the first rectangle at 0 degrees, and then rotate the second rectangle by the negative degrees of the first rectangle around the axis of the first rectangle. It works pretty well, and seems to be plenty fast, even though I have to do it twice, so I'll leave it for now.
Now I'm trying to get the collision response working with rotated rectangles. What I'm going to try, is to record all of the collision points, then register if there are left-bottom or right-bottom collisions on the rotated rectangles. If so, I'm thinking I could just increase or decrease the rotational velocity.
It makes sense and could work good-enough, but I'm curious as to how any of you have handled it. If you tell me I should just take a math class, that's not gonna happen, but I will buy any books you recommend.
Thanks,
Rich
|
|
|
|
|
9
|
Discussions / General Discussions / Re: Finishing is hard.
|
on: 2011-10-11 04:26:38
|
|
I spent a day, 8am until 9pm, working on the the rotated collision checking yesterday, and I failed. Today, went back on it, 8am, untl 2PM, and then it worked. I was just dirt dumb and rotate one rectangle back to being flat, then the other by the same amount in negative around the axis of the first rectangle. I debugged like hell. I wrote a debug canvas to see shit visually, but still no go. I finally decided to write a separate program to just test, and it didn't take long to get the routine working well. After that, I made I copy of my main collision detection class, backed up the old one, and then stripped shit down. It turns out it was just some collision escape convenience routines that were killing it. Then, all of the shit all of a suddenly worked great.
Persistence is an alternative to intelligence,
Rich
|
|
|
|
|
10
|
Discussions / General Discussions / Re: Finishing is hard.
|
on: 2011-10-09 05:01:29
|
|
Today I tried to add Separating Axis Theorem to the collision detection routines, and I failed. It sorta worked, but there were bugs all over, like being able to walk over thin air, and with a rotation of zero degrees not being able to move at all anywhere. If I rotated things only a few degrees, it worked a bit, but it wasn't tight. I decided to throw in the towel on it for this project. We have so many elements working well, and I just can't bring myself to tear shit down for something that if I'd maybe had a math class or two wouldn't have been too tough.
Having your ass kicked is a good thing though. You have to realize when to withdraw from the current battle, knowing it's not a total loss.
I'm gonna go crack a beer and listen to some Uli Jon Roth on my first day of my week off.
Metal,
Rich
|
|
|
|
|
11
|
Discussions / General Discussions / Re: Finishing is hard.
|
on: 2011-10-05 03:19:47
|
This is all that matters. Why are you so apologetic? Being bull-headed and driven is the only way to success in this adventure. You're enjoying what you do, but too concerned with the results. You said it yourself--you enjoy working on this stuff. Hell yeah dezzroy, that clicks with me. I'm just apologetic because I've been out of the internet social scene forever, and don't want to come off as a dick head. Anything I post isn't bragging, cause it's still hot on the plate stuff that I enjoy sharing. I just don't want to be too egocentric. Staying hungry is a good thing. If I were locked up, I'm sure I'd doodle out ideas too. I mean I'm not at all intelligent, but it only takes a second to realize a square has 4 sides, and after drawing it out on paper, you realize that you can set the velocity of your 2D rolling objects by something like the following: 1 2 3
| double frames_per_pixel = animation_action.getWidth()*4; frames_per_pixel/=((double)animation_action.getFrameCount()); |
I don't know if that's mathematically correct. I just drew shit on paper and tried it out. It worked. It's those little Eureka moments that make me happy and want to share. I do like setting strict timelines, and cranking out stuff, even if it will end up on the cutting room floor. I don't care if I something I do is the end-all of greatness, but I don't want to feel embarrassed about how it represents my dreams. In the end, you do it for yourself, and if you aren't content, nobody will be. I've noticed that sometimes grunt-work is necessary too. It's not all fun and inspiration. The grinding and leveling up is an awesome experience though. It's like the end of the World of Warcraft South Park episode, after it's done, "so what are we going to do now?" "Whattaya mean? We can finally play the game." Rich
|
|
|
|
|
12
|
Discussions / General Discussions / Re: Finishing is hard.
|
on: 2011-10-04 04:32:32
|
|
Thanks. I'm sorta socially retarded, and felt like a bragging idiot, so sabotaged my old account. It didn't help that I had a few beers, read some other discussions and saw the variable username insertions. In my megalomaniac stupor I didn't realize that, no, those weren't mocking jabs at me. Yes, I feel like an idiot, but that's good. Humility keeps my head on straight.
I shared a couple of years worth of work and felt like I was showing my cards when I don't know if I have a good hand. I'll continue to post updates as I hit milestones. I'd really like to be able to share levels as they are completed to get any feedback, especially negative/constructive feedback. Thanks for being understanding. For a while I'm going to catch up and read as much as I can here to digest the proper etiquette and learn a thing or two about what all of you are doing and/or have done.
Formerly Richesian,
Rich
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|