• Content count

  • Joined

  • Last visited

Community Reputation

124 Neutral

About HuwFulcher

  • Rank
  1. Any way to make this simple tennis game more OO?

      Yep.  I saw a video of Jonathan blow talking about how he coded stuff in Braid.  It was very interesting.  He would just put a comment in a function instead of creating a new funtion, wrap that code in braces, and then code away, knowing that the code wasn't going to break any other code.  From an 'OO' point of view this is just rubbish, but when you're one of a few people trying to fix a bug in a game so you can ship it, you'd rather rewrite the same code snippet 10 times and test each fix once than change a function used in thousands of spots and have to test thousands of things when you make a change. void someFunc() { // fix a bug here { // here is some code, wrapped in braces, // so the scope can't possible cause problems // anywhere else. I can change this code all // I want and not break anything else } } This may be going to far, but I really had to stop and think about it.  I'm still thinking about it...     Interesting idea! I'm going to focus on just coding out the program first and then see what can be made modular without causing too much grief in the long run
  2. Any way to make this simple tennis game more OO?

    I see, thanks for all the help I am getting a bit too carried away early since I haven't even finished the project yet haha!
  3. Any way to make this simple tennis game more OO?

    Thanks for all your input guys, this is really helpful I'll take it a step at a time and try and refine it more and more into fitting the OOP paradigm. In general for Game Development how OO should you go? I'm a little new on all of this so any more info (or if you need me to provide more) would be appreciated :)   Thanks once again!
  4. Thank you for all the birthday wishes! I've had an amazing day surrounded by amazing people!
  5. Any way to make this simple tennis game more OO?

    Cool thanks for the response! I'll take a look at modifying it now and see if I can get something working :), is the original code an acceptable form of OOP or would it need refinement? 
  6. Hey all, I'm a 1st year CS student and I'm making my first pet project in Java, the idea is taken from this tutorial ( but I didn't want to continue following the tutorial because I wanted to get my hands dirty and dive in trying to work it out myself.   Currently the code has three classes: - Game which is the main class that sets up the KeyListener, game loop and painting of the screen - Ball which creates the ball sprite and works out the position on screen when the move() and paint() methods are called - Racquet which is the same as Ball but a different shape obviously.   My question is, can I separate the Game class and make a Board class that deals with creating the window and then leave the Game class to run the loop only? I've tried doing so but I've discovered circular dependencies between Board, Ball and Racquet if I do that. I can do it using setters in the Board class to reference the Ball and Racquet class but I can't get the KeyListener working in that case and I think there must be a slicker way of doing it The code is below:   Game: import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.JPanel; /** * Created by HuwF on 24/04/2014. */ public class Game extends JPanel { //Create sprite objects Ball ball = new Ball(this); Racquet racquet = new Racquet(this); public Game() { //Implement listener to move keyboard addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { //Call racquet to move it racquet.keyPressed(e); } @Override public void keyReleased(KeyEvent e) { //Stops racquet movement racquet.keyReleased(e); } }); setFocusable(true); } //Gets objects to update position and movement values public void move() { ball.move(); racquet.move(); } //Paints screen based on sprite's values @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; ball.paint(g2d); racquet.paint(g2d); } public static void main(String[] args) throws InterruptedException { //Create and display frame JFrame frame = new JFrame("Mini Tennis"); Game game = new Game(); frame.add(game); frame.setSize(300, 400); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Main game loop - I want everything apart from this in the Board class while (true) { game.move(); game.repaint(); Thread.sleep(10); } } }   Ball: import java.awt.Graphics2D; /** * Created by HuwF on 24/04/2014. */ public class Ball { //Ball coordinates int x = 0; int y = 0; //1 = Right, 0 = Still, -1 = Left int xDirection = 1; //1 = Up, 0 = Still, -1 = Down int yDirection = 1; private Game game; public Ball(Game game) { game; } void move() { //If ball is by left edge of screen, direction reverses if (x + xDirection < 0) { xDirection = 1; } //If ball is by right edge of screen, direction reverses if (x + xDirection > - 30) { xDirection = -1; } //If ball is by the bottom of screen, direction reverses if (y + yDirection < 0) { yDirection = 1; } //If ball is by the top of screen, direction reverses if (y + yDirection > - 30) { yDirection = -1; } //If ball is no where near screen border continue along path x = x + xDirection; y = y + yDirection; } public void paint(Graphics2D g) { //Draw sprite on screen g.fillOval(x, y, 30, 30); } } Racquet: import java.awt.*; import java.awt.event.KeyEvent; /** * Created by HuwF on 24/04/2014. */ public class Racquet { //Position, racquet can only move left or right int x = 0; //Direction, -1 = Left, 0 = Still, 1 = Right int xDirection = 0; private Game game; public Racquet(Game game) { = game; } public void move() { //If not near the left or right edge of the screen then move in current direction if ((x + xDirection > 0) && (x + xDirection < - 60)) { x = x + xDirection; } } public void paint(Graphics2D g) { //Draw sprite on screen g.fillRect(x, 330, 60, 10); } //When a key is released the racquet stops moving public void keyReleased(KeyEvent e) { xDirection = 0; } public void keyPressed(KeyEvent e) { //If left arrow is pressed direction is changed to left if (e.getKeyCode() == KeyEvent.VK_LEFT) { xDirection = -1; } //If right arrow is pressed direction is changed to right if (e.getKeyCode() == KeyEvent.VK_RIGHT) { xDirection = 1; } } } Thanks in advance!
  7. 3ds Max 2012 Review

    Looks great wish I could use it in my spare time but the price puts me off. Looks like Blender for me!
  8. How do the maps work in Civilization?

    [quote name='bluntman' timestamp='1309263043' post='4828624'] [quote name='Huwtrosky' timestamp='1309262676' post='4828622'] Wouldn't constantly drawing the whole map be a massive drain on the machine running it? [/quote] It depends on how costly it is to draw the map. Obviously it isn't optimal, but it would achieve what he originally wanted, while requiring barely any modifications to his code. [/quote] Good point
  9. How do the maps work in Civilization?

    [quote name='bluntman' timestamp='1309190774' post='4828300'] [quote name='beatlefan' timestamp='1309186439' post='4828264'] Thanks guys. I wasn't going to use tiles, but I suppose if I sliced the terrain up into tiles it still work. [/quote] Yep, your tiles don't have to be 1x1 though, in fact they could be the size of the entire map, so you are constantly drawing the whole map four times.. [/quote] Wouldn't constantly drawing the whole map be a massive drain on the machine running it?
  10. Planning for the future

    [quote name='Domx' timestamp='1302523952' post='4797075'] [quote]4. I meant I have emailed both Bungie and Lionhead. I'm not expecting a response back any time soon but I was asking which degree for game programming they look for more. CS or Computer Games Programming.[/quote] Having worked at Lionhead I can tell you that pretty much all of their programmers had a CS degree and any person doing an internship there was a CS student. They usually respond to e-mails like yours, so you might hear back from them and get some extra encouragement to take a CS degree route. [/quote] Sadly I haven't had an email back from Lionhead or Bungie but it doesn't matter I'm sure on what I'm going to do now.
  11. Planning for the future

    [quote name='GesterX' timestamp='1302171340' post='4795448'] [quote name='Huwtrosky' timestamp='1301823032' post='4793776'] I have another query, this time it is geared towards what subjects are called. In my school (UK) we have the option of Computing to take at A level (the final grades before heading to Uni), obviously this A level is a definite choice for me. Having a look through the University Computer Science league boards my top option which is ranked 19th is Nottingham which would like an A level in Computer Science. Is Computing and Computer Science the same thing? If it is then this will be a real help to me! [/quote] I didn't know they did A-Levels in Computer Science! All my Sixth Form did was ICT :-( Anyway I am 90% sure Computing A-Level is the same as Computer Science A-Level. Best thing to do is ask your school/college or phone Nottingham and ask them. Nottingham is a good Uni - it's recently been refurbished. I am currently in the final year of Computer Science at Aston University (which is ranked quite high and getting better every year) and can definitely reccommend it (not too far from Wales either!). I agree with eveyone elses comments. A degree in Computer Science will definitely be seen as a "better" degree than the Game Programming ones. I'm currently applying for positions in the Games Industry and almost every position requires a degree in Computer Science. Saying that, don't expect to come out of Uni and instantly get a Games Industry job. Jobs in the UK are really scarce at the moment so you have to do everything you can to secure the job you want. This means you need a portfolio and that's something you can start doing right away! From my experience at this is the path you want to follow: [list=1][*]Begin learning to program now. Start with something like Python or C#. Also take a look at Flash, UDK and Unity3D.[*]Choose your A-Levels. Subjects I reccomend to a future CS student are Computing, Maths and Physcis. If you get to pick one more then look at English, Pyschology, Media Studies, or Art (if your good at it!)[*]In Year 13 you may be able to take "General Studies". Take it, most Universities will allow you to include the score in your UCAS points tally. It's easy - just general English. Maths, Science and RE stuff.[*]Continue to learn programming whilst doing your A-Levels and start building up a portfolio of simple projects (your A-Levels should be your main focus though!)[*]Get at least a B in all your A-Levels![*]Go to Uni and study Computer Science.[*]In the first year of Uni you will have quite a lot of free time. Use this time to work hard on your portfolio![*]The 2nd year of Uni counts as about 25% of your final result so work hard! It's for real now![*]Try and get a placement for the 3rd year. A Game Industry placement is prefferable but any placement will still give you a massive advantage in getting your first job.[*]Final Year of Uni. Hopefully by now you'll have a nice portfolio and can concentrate all your efforts on getting a good grade. In final year you have a large "final year project" to complete which counts towards about 25% of your final grade. Most places will allow you to choose whatever you like for this project so use this opportunity and make a game - the Computing Department at your Uni will be able to help you with how big it should be and how to maximise your grade.[*]If you haven't lost the will to live - get a job in the Games Industry! YAY! Your hardwork paid off![/list] Hope this extensive (and quite frankly rambling) post helped! [/quote] Sorry for bringing up a dead thread but that was some amazing advice! Thanks alot for this I've started learning Python and have some beginners knowledge of C# but I'm gonna focus on Python then finish up on C# then learn Java
  12. I agree with Tom once you have finished your degree you'll be better equipped (hopefully) to dive into Games Programming. Does your degree have optional modules? If so some may help with games programming for example when studying what uni I want to go to for Computer Science Nottingham Uni has Graphical User Interfaces, AI programming techniques. On saying this I would say don't put all your eggs in one basket. Do modules which interest you as well as a few linked to games programming because you may found a job you find much more interesting and exciting.
  13. C, C# or C++?

    Does Python have similar syntax? I've made a little application with C# before so it should be easier to get to grips with
  14. C, C# or C++?

    Okay I want to learn a few game programming languages to get a head start in Uni but I'm not sure which of the three in the topic is best to start out with. Once I have a good knowledge of one or two of the above languages I will move onto Python and Java to cover all the bases
  15. Problem writing string array's to text file.

    [quote name='avelle' timestamp='1301889399' post='4794044'] [quote name='Huwtrosky' timestamp='1301854736' post='4793891'] Well set it to loop but now I'm having a problem with the File.WriteAllText line. The problem is that when debugging I get the NotSupportedException pop up. I can't see what I'm doing wrong [img][/img] Here's the new code Fixed now [/quote] I think there's a few things you can improve on here. [code] for (int i = 0; i < 5; i++) { SheetWriter = contents[i] + "\r\n"; } [/code] For this loop, SheetWriter is just a string right? If you want to keep appending contents[i] with the carriage return, you need to use += or you'll just keep rewriting the data every iteration. Though it's not super important in this example, you can also use contents.Length for your loop and if you ever need to change the size of your array someday you won't have to worry about hardcoding the iterations. Lastly for writing the data to file, you can just use a string array, but I believe you need to use File.WriteAllLines. It takes the same arguments as WriteAllText but it should write the contents of an array. [code] File.WriteAllLines( file_name, contents ); [/code] Here's the example on msdn: [url=""]http://msdn.microsof...y/92e05ft3.aspx[/url] That should work, but I'm going off memory right now so my syntax might be off. Hope that helps. [/quote] Like what you quoted I've fixed it now the final code is [code]using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace Oblivion_Character_Sheet { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string SheetWriter; private void btnProcess_Click(object sender, EventArgs e) { string[] contents = new string[5]; contents[0] = "Name: " + txtBoxName.Text; contents[1] = "Race: " + txtBoxRace.Text; contents[2] = "Birthsign: " + txtBoxBirth.Text; contents[3] = "Class: " + txtBoxClass.Text; contents[4] = "Other info: " + rchtxtBoxOther.Text; for (int i = 0; i < 5; i++) { SheetWriter = SheetWriter + contents[i] + "\r\n"; File.WriteAllText(txtBoxPath.Text, SheetWriter); } } } } [/code]