ChristofferKrook

Member
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

121 Neutral

About ChristofferKrook

  • Rank
    Newbie
  1. 2D Game Programming for Windows Store

    http://www.xnadevelopment.com/tutorials.shtml XNA is used for WP (and tablets?). There are loads of tutorials on the net, just google xna tutorials
  2. Which method to use for drawing?

    The one wich is the most obvious to me would be spriteBatch.Draw()..? Pass spritebatch the the respective classes of the items and draw it directly from the class.
  3. d3dx11.lib why you haunt me?
  4. Thanks! That solved it! Thank you for putting your time into this! ^^ Now i just need to improve this retarded/unbeatable AI...
  5. Hey there! I just finished up a little pong clone to show a friend interested in beginning programming, but now when i thought i was "done", i realise that the program just freezes.. nothing is alive. I know this due to System.out.println(); not working when it is frozen. Could someone here please help me? Thanks in advance! I know i am asking alot, but really, thanks [CODE] import java.awt.*; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import java.util.Random; import javax.swing.JFrame; public class Main extends Canvas implements Runnable{ // //variables // // private keyListener input = new keyListener(this); private static final long serialVersionUID = 1L; public static final int HEIGHT = 200 * 5; public static final int WIDTH = 320 * 5; private boolean running = false; public Rectangle bbox1, bbox2, bbox3; private BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); public int enemySpeed = 1; public int ballSpeedX = 4; public int ballSpeedY = 4; public int posX, posY, width, height, enemyX, enemyY, score, enemyScore; public int ballPosX, ballPosY; boolean someoneScored = false; int newDir; // // //main // // public Main(){ posX = 80; posY = HEIGHT/2 - 80; width = 40; height = 160; enemyX = WIDTH - 80 - width; enemyY = posY; ballPosX = WIDTH / 2 - 20; ballPosY = HEIGHT / 2 - 20; score = 0; enemyScore = 0; } public void start(){ running = true; new Thread(this).start(); } public void stop(){ running = false; } public void run() { while(running){ loop(); } } public void loop(){ tick(); render(); } // // //gameloop // // public void tick(){ if(input.up){ System.out.println("I am still alive"); posY -= 1; } if(input.down){ System.out.println("I am still alive"); posY += 1;; } if(input.enter && someoneScored == true) relaunchBall(); bbox1 = new Rectangle(enemyX, enemyY, width, height); bbox2 = new Rectangle(ballPosX, ballPosY, 40, 40); bbox3 = new Rectangle(posX, posY, width, height); if(bbox1.intersects(bbox2)){ } ballPosX += ballSpeedX / 2; ballPosY += ballSpeedY / 2; if(ballPosY >= HEIGHT - 40){ ballSpeedY *= -1; } if(ballPosX >= WIDTH - 40){ ballPosX = WIDTH / 2 - 40; } if(ballPosY < 0){ ballSpeedY *= -1; } if(ballPosY <= enemyY + 80){ enemyY -= 1; } if(ballPosY >= enemyY + 80){ enemyY += 1; } if(ballSpeedX <= 0){ moveTowardsCenter(); } if(ballPosX >= enemyX){ someoneScored = true; score += 1; ballPosX = WIDTH / 2 - 20; ballPosY = HEIGHT / 2 - 20; ballSpeedX = 0; ballSpeedY = 0; } if(ballPosX <= 0){ enemyScore += 1; ballPosX = WIDTH / 2 - 20; ballPosY = HEIGHT / 2 - 20; ballSpeedX = 0; ballSpeedY = 0; someoneScored = true; } if(bbox1.intersects(bbox2)){ ballPosX -= 4; ballSpeedX *= -1; } if(bbox3.intersects(bbox2)){ ballPosX += 4; ballSpeedX *= -1; } //System.out.println(posY); } // // //drawing // // public void render(){ BufferStrategy bs = getBufferStrategy(); if(bs == null){ createBufferStrategy(3); return; } Graphics g = image.getGraphics(); g.setColor(Color.BLACK); g.fillRect(0, 0, WIDTH, HEIGHT); //g.dispose(); g = bs.getDrawGraphics(); g.drawImage(image, 0, 0, getWidth(), getHeight(), null); //Draw here. g before g.setColor(Color.RED); g.fillRect(posX, posY, width, height); g.fillRect(enemyX, enemyY, width, height); g.fillOval(ballPosX, ballPosY, 40, 40); g.drawString("Score: " + score, 50, 60); g.drawString("EnemyScore: " + enemyScore, WIDTH - 150, 60); if(someoneScored){ g.drawString("Press enter to relaunch the ball", WIDTH/2, 80); } g.dispose(); bs.show(); } // // //for "dead" ball // // void relaunchBall(){ Random r = new Random(); newDir = r.nextInt(4); someoneScored = false; System.out.println(newDir); switch(newDir){ case 0: ballSpeedX = 4; ballSpeedY = 4; break; case 1: ballSpeedX = 4; ballSpeedY = -4; break; case 2: ballSpeedX = -4; ballSpeedY = -4; break; case 3: ballSpeedX = -4; ballSpeedY = 4; break; } } // // //For the ball to move towards the center when the ball is going towards the player // // void moveTowardsCenter(){ int desiredPos = HEIGHT / 2; int realYValue = enemyY + 80; if(realYValue <= desiredPos){ enemyY += 1; } if(realYValue >= desiredPos){ enemyY -= 1; } while(realYValue == desiredPos){ enemyY = HEIGHT / 2 - 80; } } public static void main(String[] args){ Main game = new Main(); game.setMinimumSize(new Dimension(WIDTH, HEIGHT)); game.setMaximumSize(new Dimension(WIDTH, HEIGHT)); game.setPreferredSize(new Dimension(WIDTH, HEIGHT)); JFrame frame = new JFrame("Pong"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(game); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); game.start(); } } [/CODE]
  6. Thank god it's friday!
  7. Can someone tell me the basics

    I'm pretty sure you'll find out when you start the course... Anything works really... C#, JAVA, C++, Python just to name a few.
  8. Creating an engine like Prelude Of The Chambered

    [quote name='Daimon' timestamp='1322209195' post='4887558'] [quote name='Dakk' timestamp='1322166462' post='4887383'] Ok, i changed my mind. There are NO good tutorials for this. Where did you learn how to do this? This is advanced for me. The document you linked shows very well WHAT to achieve and WHAT i need to do, but it does not show HOW i do it. [/quote] Hello, just because it does not provide a lot of pseudocode (or code snippets in any language) it does not mean that it does not show you HOW to do it. Yes, it seems very theoretical at first, but reading it carefully and taking notes should bring you closer to your goal. It is easier to implement once you understand the concept :-) Also, at the end of the tutorial is a download link for an example project using this technique in java, which should help you understand it better. If there are still specific points unclear, feel free to ask! [/quote] I cannot execute the code in Eclipse. I can open it and view it, but i cannot run it :/ Any idea of why? Could you provide a simple and better commented example? (I know i am asking for alot, sorry :/) Thanks in advance
  9. Creating an engine like Prelude Of The Chambered

    [quote name='Dakk' timestamp='1322053553' post='4886866'] [quote name='Daimon' timestamp='1322047981' post='4886848'] [quote name='Dakk' timestamp='1321982350' post='4886610'] I have No idea at all of how to create this 2.5D(?) engine. It is composed with minecraft like block walls and the enemies and such are billboarded to allways face you. I tried thinking it over, and i tried to make it, and i have yet to succed. He does it in a really smart way. He has an image wich the colour of a pixel decides what "block" will be placed there.. [b]Could someone here please think it over and try to write down how one would create this type of engine? I dont mean post the complete code, but just pseudo code the techniques used and expain the mindset one would require.[/b] Thanks in advance! Here is the creating of / video of end result [url="http://www.youtube.com/watch?v=KcfFJ6pNEZk"]http://www.youtube.c...h?v=KcfFJ6pNEZk[/url] and here is the source code (I cannot understand it that well since iäve programmed for just 1.5 years and i am not at that level where i can just read code and understand it) [url="http://www.ludumdare.com/compo/ludum-dare-21/?action=preview&uid=398"]http://www.ludumdare...preview&uid=398[/url] [/quote] Hello Dakk! Maybe you should check out this tutorial: [url="http://www.permadi.com/tutorial/raycast/index.html"]http://www.permadi.c...cast/index.html[/url] it explains the theory behind creating a ray casting, or "2.5D" Engine. I hope this will help you! On a completely unrelated note, I'm currently using the techniques from this document to create an oldschool ray casting engine for the console, ASCII Art shading included: [url="http://imageshack.us/photo/my-images/100/asciic.jpg/"][img]http://img100.imageshack.us/img100/4673/asciic.jpg[/img][/url] Uploaded with [url="http://imageshack.us"]ImageShack.us[/url] [/quote] Oh my god! I cannot thank you enough! This is EXACTLY what i was looking for! thank you! [/quote] Ok, i changed my mind. There are NO good tutorials for this. Where did you learn how to do this? This is advanced for me. The document you linked shows very well WHAT to achieve and WHAT i need to do, but it does not show HOW i do it.
  10. Creating an engine like Prelude Of The Chambered

    [quote name='Daimon' timestamp='1322047981' post='4886848'] [quote name='Dakk' timestamp='1321982350' post='4886610'] I have No idea at all of how to create this 2.5D(?) engine. It is composed with minecraft like block walls and the enemies and such are billboarded to allways face you. I tried thinking it over, and i tried to make it, and i have yet to succed. He does it in a really smart way. He has an image wich the colour of a pixel decides what "block" will be placed there.. [b]Could someone here please think it over and try to write down how one would create this type of engine? I dont mean post the complete code, but just pseudo code the techniques used and expain the mindset one would require.[/b] Thanks in advance! Here is the creating of / video of end result [url="http://www.youtube.com/watch?v=KcfFJ6pNEZk"]http://www.youtube.c...h?v=KcfFJ6pNEZk[/url] and here is the source code (I cannot understand it that well since iäve programmed for just 1.5 years and i am not at that level where i can just read code and understand it) [url="http://www.ludumdare.com/compo/ludum-dare-21/?action=preview&uid=398"]http://www.ludumdare...preview&uid=398[/url] [/quote] Hello Dakk! Maybe you should check out this tutorial: [url="http://www.permadi.com/tutorial/raycast/index.html"]http://www.permadi.c...cast/index.html[/url] it explains the theory behind creating a ray casting, or "2.5D" Engine. I hope this will help you! On a completely unrelated note, I'm currently using the techniques from this document to create an oldschool ray casting engine for the console, ASCII Art shading included: [url="http://imageshack.us/photo/my-images/100/asciic.jpg/"][img]http://img100.imageshack.us/img100/4673/asciic.jpg[/img][/url] Uploaded with [url="http://imageshack.us"]ImageShack.us[/url] [/quote] Oh my god! I cannot thank you enough! This is EXACTLY what i was looking for! thank you!
  11. I have No idea at all of how to create this 2.5D(?) engine. It is composed with minecraft like block walls and the enemies and such are billboarded to allways face you. I tried thinking it over, and i tried to make it, and i have yet to succed. He does it in a really smart way. He has an image wich the colour of a pixel decides what "block" will be placed there.. [b]Could someone here please think it over and try to write down how one would create this type of engine? I dont mean post the complete code, but just pseudo code the techniques used and expain the mindset one would require.[/b] Thanks in advance! Here is the creating of / video of end result [url="http://www.youtube.com/watch?v=KcfFJ6pNEZk"]http://www.youtube.c...h?v=KcfFJ6pNEZk[/url] and here is the source code (I cannot understand it that well since iäve programmed for just 1.5 years and i am not at that level where i can just read code and understand it) [url="http://www.ludumdare.com/compo/ludum-dare-21/?action=preview&uid=398"]http://www.ludumdare...preview&uid=398[/url]