Show Posts
|
|
Pages: [1]
|
|
1
|
Game Development / Newbie & Debugging Questions / Re: Putting my Slick game into a website
|
on: 2013-01-13 15:33:51
|
Thank you for helping me, the problem is fixed  But...a new error has now occurred  I can load up the html code now and now it has gotten further than it has ever gotten, it asks for my permission to load java, I accept and run it, I see the lwjgl loading bar, then another error pops up this time saying: An error occured while loading the applet. Please contact support to resolve this issue. This occured while 'Downloading packages'. What would cause this error? Please note the quotes. Haha, it amazes me how such a small mistake can cause the full program running, I make sure to check everything over 5 times before I try run it now 
|
|
|
|
|
3
|
Game Development / Newbie & Debugging Questions / Re: Putting my Slick game into a website
|
on: 2013-01-12 22:28:24
|
|
Sorry for the confusing previous post, I have fixed the error that was occurring previously, it was a missing quotation at the al_title param but now have a new error: Permissions for Applet Refused. Please accept the permissions dialogue to allow the applet to continue the loading process.
This was after pressing the "run this time" option.
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / Re: Putting my Slick game into a website
|
on: 2013-01-12 21:46:29
|
|
I am using eclipse so I have made 3 folders, lib and under lib I have made jars and natives, inside my natives I have put 4 natives (windows, linux, solaris, macosx), in my jars the only two are slick.jar and lwjgl.jar. In my java library under my Java build path I have only imported the two jars (lwjgl and slick) and windows only not the other 3 OS, do I need to import all of my jars from lwjgl_jar into eclipse and my java build path, files such as AppletJavaExtensions.jar, Izma.jar,lwjgl_test.jar,etc...? also do I have to import all of the natives into eclipse or will it work with just windows?
Thank you.
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: Putting my Slick game into a website
|
on: 2013-01-12 21:22:33
|
|
I have found the solution and may have been too obvious for many users on this forum to answer but it was not having my html file with my ljgl_util_appler.jar, I now put them together in the same directory but get another error on the centre of my screen: An error occurred while loading the applet. Please contact support to resolve this issue. missing reqired applet parameter: al_main.
I have looked inside slick for the ApplerGameContainer but I can only find chrome files, I tried putting these in the same directory as the html file but I still get the same error.
If you have any information that may help to me, even if it may be a very obvious thing to do, then please tell me as I am new to Java and will probably have missed something very simple.
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: Putting my Slick game into a website
|
on: 2013-01-12 11:25:12
|
|
I have looked inside my jar file (racegame.jar) with winrar and found that there are 3 different folders, one is my game package (javagame) which holds all of my class files, the second one is the META-INF which holds a file called MANIFEST.MF and my third folder is called org and this holds both lwjgl and newdawn (which holds slick) folders. The contents within the game I made in eclipse are slick and lwjgl which I imported into eclipse, many images which I used for my game and the code. Natives were also loaded into eclipse but the only one I imported into the Java Library was the windows native.
If the information above is not enough please tell me and I will give you the racecar.jar file.
Thank you.
EDIT: It may also be worth mentioning that I am just running my html code from my desktop and not from a website at the moment.
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Putting my Slick game into a website
|
on: 2013-01-11 22:27:42
|
I have made a GUI in Java using State Based Game, as it extends StateBasedGame and not JApplet its not a true applet, I want to put it on a website and am unsure on how to do this, I have been told that the following code allows me to make this into an applet using html and not having to edit the Java code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <applet code="org.lwjgl.util.applet.AppletLoader" archive="org.lwjgl.util.applet.AppletLoader" codebase="." width="640" height="480">
<param name="al_title" value="Ham Blaster"> <param name="al_main" value="org.newdawn.slick.AppletGameContainer"> <param name="game" value="org.javagame.Game">
<param name="al_jars" value="racegame.jar, lwjgl.jar, slick.jar">
<param name="al_windows" value="windows_natives.jar"> <param name="al_linux" value="linux_natives.jar"> <param name="al_mac" value="macosx_natives.jar">
<param name="separate_jvm" value="true"> </applet> |
I found the code on a forum and modified it to work with my game, the link to the forum is http://ninjacave.com/slickapplet I run that on html and get the following error message: org.lwjgl.util.applet.AppletLoader even though there is a AppletLoader class in my lwjgl. If you can help me fix the above code then please tell me but if not possible please give me another method of putting my GUI onto a website. Also, It may be worth mentioning, when I made my Java GUI, I had imported lwjgl and slick into eclipse, so I am assuming they are also in my racegame.jar file.
|
|
|
|
|
9
|
Java Game APIs & Engines / Java 2D / Re: Please help me with collisions
|
on: 2012-12-11 12:50:01
|
Can anyone please tell me how to make a rectangle around my player and my house, am I supposed to use the code bellow? 1 2 3
| public Rectangle getBounds() { return new r1(x, y, width, height); } |
If so, where do I place this code in my code?
|
|
|
|
|
10
|
Java Game APIs & Engines / Java 2D / Re: Please help me with collisions
|
on: 2012-12-10 23:39:37
|
Thank you for helping me Matheus23, I am sorry for asking noob questions but could you please tell me how I would continue after making the Rect class please, I think I have a basic Idea of what I need to do but keep messing up, so to start off, is this how I would make the rectangles: 1 2 3
| public Rectangle getBounds() { return new r1(x, y, width, height); } |
So I would make 2 of the above code, 1 for the house and one for the car, but would I have to make a object of the Rect class to be able to do this? Also, under what section of code would I place this, would it be under my Render method or my Update method or something else? The I would have to place your if statement into my code, but again,where would this be placed(in the render, update, other)?
|
|
|
|
|
11
|
Java Game APIs & Engines / Java 2D / Re: Please help me with collisions
|
on: 2012-12-10 22:51:43
|
Thank you for the help, Matheus23, the code you ave shown in your post: 1 2 3 4 5 6 7 8 9 10
| public static boolean rectVsRect(Rect r1, Rect r2) { if ((r1.x >= (r2.x + r2.w)) || ((r1.x + r1.w) <= r2.x)) { return false; } if ((r1.y >= (r2.y + r2.h)) || ((r1.y + r1.h) <= r2.y)) { return false; } return true; } |
How do I put this code into my code and how do I set up my r1 and r2 to be my player(the car) and the collision (the house)?
|
|
|
|
|
12
|
Java Game APIs & Engines / Java 2D / Re: Please help me with collisions
|
on: 2012-12-10 21:39:08
|
Thank you for the replies. P0jahn then link you had posted seems very interesting and helpful but as I am a noob with Java I am having a hard time understanding exactly what I have to do, I would like to use the first code on the website (which seems to be the simplest): 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
| short int Sprite_Collide(sprite_ptr object1, sprite_ptr object2) { int left1, left2; int right1, right2; int top1, top2; int bottom1, bottom2; left1 = object1->x; left2 = object2->x; right1 = object1->x + object1->width; right2 = object2->x + object2->width; top1 = object1->y; top2 = object2->y; bottom1 = object1->y + object1->height; bottom2 = object2->y + object2->height; if (bottom1 < top2) return(0); if (top1 > bottom2) return(0); if (right1 < left2) return(0); if (left1 > right2) return(0); return(1); }; |
Am I correct in thinking object one and object two are the two rectangles that I need to make around my player and the house on the map? If so, how exactly do I make these rectangles and where do I place the code above and the rectangle code in my code(under the render method, update method or something else)? Also, would this code work if I wanted to set up more than one collision, for example my map contains many houses, would this code work for that or would a Recatngle getBound() type method with a if (intersects) way work better? (I dont really know either of them two very well but types of code have seen a bit of both done before) I am sorry for asking all these questions which may seem very easy to you, I am new with Java and might take a while to understand simple things. Thank you.
|
|
|
|
|
13
|
Java Game APIs & Engines / Java 2D / Please help me with collisions
|
on: 2012-12-09 14:44:36
|
I am fairly new to Java and after studying most of the basics I started making a 2D state change game with the help of online tutorials, the game is a simple car racing game with a overhead view kind of like pokemon, with simple left right forward backward and diagonal movements. I have got everything I need and have written most of the code but am stuck with collisions. I understand the basic concept of setting up collisions (or at least I think I do) and the way I have seen it done in the past is you set a rectangle around the car and a rectangle around the object on the map and set an if statement saying if intersects change direction to - or something similar to that, but am having trouble putting this into my code and am hoping some of the more experienced users could help me out, the code for my game is shown below, I have not posted things like the menu class and the main class just because it would overcrowd things, but if needed please tell me. The collision I want to set is a rectangle at coordinates: Top left: -115, -100 Top right: -360, -100 Bottom right: -360, -280 Bottom left: -115, -280 and the rectangle of my car which is a 40x40 image. I would just like this one collision to be explained to me or shown to me in my code and I will be able to set all the others on my own with the knowledge I gain from this one. 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
| package javagame; import org.newdawn.slick.*; import org.newdawn.slick.state.*; public class Play extends BasicGameState{ Animation bucky, movingUp, movingDown, movingLeft, movingRight, movingBL, movingBR, movingFL, movingFR; Image worldMap; boolean quit = false; int[] duration = {200, 200}; float buckyPositionX = 0; float buckyPositionY = 0; float shiftX = buckyPositionX + 320; float shiftY = buckyPositionY + 160; public Play(int state){ } public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{ worldMap = new Image("res/world.png"); Image[] walkUp = {new Image("res/b.png"), new Image("res/b.png")}; Image[] walkDown = {new Image("res/f.png"), new Image("res/f.png")}; Image[] walkLeft = {new Image("res/l.png"), new Image("res/l.png")}; Image[] walkRight = {new Image("res/r.png"), new Image("res/r.png")}; Image[] walkBL = {new Image("res/bl.png"), new Image("res/bl.png")}; Image[] walkBR = {new Image("res/br.png"), new Image("res/br.png")}; Image[] walkFL = {new Image("res/fl.png"), new Image("res/fl.png")}; Image[] walkFR = {new Image("res/fr.png"), new Image("res/fr.png")}; movingUp = new Animation(walkUp, duration, false); movingDown = new Animation(walkDown, duration, false); movingLeft = new Animation(walkLeft, duration, false); movingRight = new Animation(walkRight, duration, false); movingBL = new Animation(walkBL, duration, false); movingBR = new Animation(walkBR, duration, false); movingFL = new Animation(walkFL, duration, false); movingFR = new Animation(walkFR, duration, false); bucky = movingDown; } public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{ worldMap.draw(buckyPositionX, buckyPositionY); bucky.draw(shiftX, shiftY); g.drawString("Suraj's X: "+buckyPositionX+"\nSuraj's Y: "+buckyPositionY,400,20); if(quit==true){ g.drawString("Resume(R)", 250, 100); g.drawString("Main(M)", 250, 150); g.drawString("Quit Game(Q)", 250, 200); if(quit==false){ g.clear(); } } } public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{ Input input = gc.getInput(); if(input.isKeyDown(Input.KEY_UP)){ bucky = movingUp; buckyPositionY += 10;; if(buckyPositionY>162){ buckyPositionY -= 10; } } if(input.isKeyDown(Input.KEY_DOWN)){ bucky = movingDown; buckyPositionY -= 10; if(buckyPositionY<-600){ buckyPositionY += 10; }} if(input.isKeyDown(Input.KEY_LEFT)){ bucky = movingLeft; buckyPositionX += 10; if(buckyPositionX>324){ buckyPositionX -= 10; }} if(input.isKeyDown(Input.KEY_RIGHT)){ bucky = movingRight; buckyPositionX -= 10; if(buckyPositionX<-840){ buckyPositionX += 10; }} if(input.isKeyDown(Input.KEY_RIGHT) && input.isKeyDown(Input.KEY_UP)){ bucky = movingBR; buckyPositionX -= delta * .1f; if(buckyPositionX<-840){ buckyPositionX += delta * .1f; if(buckyPositionY>162){ buckyPositionY -= delta * .1f; }}} if(input.isKeyDown(Input.KEY_LEFT) && input.isKeyDown(Input.KEY_UP)){ bucky = movingBL; buckyPositionX -= delta * .1f; if(buckyPositionX>324){ buckyPositionX -= delta * .1f; if(buckyPositionY>162){ buckyPositionY -= delta * .1f; }}} if(input.isKeyDown(Input.KEY_RIGHT) && input.isKeyDown(Input.KEY_DOWN)){ bucky = movingFR; buckyPositionX -= delta * .1f; if(buckyPositionY<-600){ buckyPositionY += delta * .1f; if(buckyPositionX<-840){ buckyPositionX += delta * .1f; }}} if(input.isKeyDown(Input.KEY_LEFT) && input.isKeyDown(Input.KEY_DOWN)){ bucky = movingFL; buckyPositionX -= delta * .1f; if(buckyPositionY<-600){ buckyPositionY += delta * .1f; if(buckyPositionX>324){ buckyPositionX -= delta * .1f; }}} if(input.isKeyDown(Input.KEY_ESCAPE)){ quit=true; } if(quit==true){ if(input.isKeyDown(Input.KEY_R)){ quit = false; } if(input.isKeyDown(Input.KEY_M)){ sbg.enterState(0); } if(input.isKeyDown(Input.KEY_Q)){ System.exit(0); } } } public int getID(){ return 1; } } |
Thank you for your help in advance.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|