• What Are You Working On? V13
    5,003 replies, posted
I'm trying to make a program that checks if the inserted year is a leap year. I barely know how that works so there is of course plenty of problems. [code] import javax.swing.JOptionPane; public class leapyear { public static void main(String[] arg) { String s = JOptionPane.showInputDialog(null, "Type in a year.", "2012"); int i = Integer.parseInt(s); int v = Calendar.leap(i); if (v % 2 != 1);{ JOptionPane.showMessageDialog(null, i + " is a leapyear."); [b]else // Broken[/b] JOptionPane.showMessageDialog(null, i + " is not a leapyear."); } } static class Calendar { public static int leap (int year) { if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) return 1; else return 2; } } } [/code] On the highlighted "else" in my last if batch (is that's what it is called in English?) it keeps saying error, delete token. I want to check whether the returned value is 1 or 2. Where 1 = Leapyear. Very simple in my mind. But Eclipse keep whining. No idea why it doesn't work. I'll probably just ask in the "need help" thread.
} else { actually I might be wrong but that's what looks like could be wrong
There shouldn't be a semi-colon after the if and if you start the { on the if, you need to close it in the if, not the else. So it would be like if (condition) { code; } else code;
Thanks guys! [editline]18th October 2010[/editline] -Fixed
I'm kind of bored right now and the idea of writing a software OpenGL renderer appeals to me. You could use it to render stuff on-demand for web based applications or debugging existing OpenGL applications by linking with it. For example, stencil buffer things are hard to debug. Good idea or not?
Good idea
Go for it
I'm not sure if I posted this yet (probably did) but I figured out the memory leak. It apparently was with the text rendering, so I guess I need to use images instead. But it still leaves to a problem where the CPU for it is around 50. Bugger.
[QUOTE=Overv;25494476]I'm kind of bored right now and the idea of writing a software OpenGL renderer appeals to me. You could use it to render stuff on-demand for web based applications or debugging existing OpenGL applications by linking with it. For example, stencil buffer things are hard to debug. Good idea or not?[/QUOTE] [url]http://en.wikipedia.org/wiki/WebGL[/url]
[QUOTE=DevBug;25498272][url]http://en.wikipedia.org/wiki/WebGL[/url][/QUOTE] Offscreen rendering, e.g. PHP bindings.
Trying to get sdl working... Error 1 fatal error C1083: Cannot open include file: 'inttype.h': No such file or directory c:\sdl\include\sdl_stdinc.h 66 What the fuck [editline]19th October 2010[/editline] Ah. I havent even got that file. [editline]19th October 2010[/editline] Wait- Yes I do it is just referenced with cps My key isnt working. I will fix in min
I'm workin' on my Design Document to help priorities and modulate everything in my engine, and I was trying to indent a group of lines at the same time, so I selected what I wanted to indent and hit tab, it all disappeared. Easily saved by Ctrl+Z, but I hate when coding habits bleed into other things :(
Oh my god. I just finished this and it worked perfectly on my first try. I just feel so happy right now. I KNEW this would have some complicated as fuck error in it, but it didn't. Fuck. Yes. [img]http://i120.photobucket.com/albums/o181/SamPerson12345/FLAWLESSVICTORY.png[/img]
[QUOTE=Overv;25498485]Offscreen rendering, e.g. PHP bindings.[/QUOTE] I stand corrected. *cough* Ruby on Rails *cough* Would it even work?
I'm trying to make a very simple platforming game but I don't know where to start. I don't even know if I can use the the HGE engine for platformers.
After looking at my program again, the code I have written was not as complex as I had remembered it being. There are only like, two lines of actually heavy math throughout the entire thing, and one of them is sort of like the inverse of the other. I guess the concept and planning were harder than the actual programming.
I've been doing way to much iOS and Objective-C. I need to do some real programming, but I cant come up with any ideas. :saddowns:
[QUOTE=Xion12;25500636]I'm trying to make a very simple platforming game but I don't know where to start. I don't even know if I can use the the HGE engine for platformers.[/QUOTE] I don't see why you couldn't it doesn't seem geared toward any specific genre save for 2D ofc. You could always try a Facewound clone :P
[QUOTE=Xion12;25500636]I'm trying to make a very simple platforming game but I don't know where to start. I don't even know if I can use the the HGE engine for platformers.[/QUOTE] Start by creating a basic Hello, world, get a character moving around the screen, reduce the amount of code you need to write to make it happen as much as possible. Then just keep on adding parts of the game.
[QUOTE=Vbits;25503235]reduce the amount of code you need to write to make it happen as much as possible.[/QUOTE] I really wouldn't even worry about doing this. I don't know whether you're implying refactoring or optimization but both are really kinda of wasteful in early implementation. Early implementation is about getting the basic idea functional and running, testing out other new things, removing things that don't work towards that idea. Optimizing and refactoring in the early run doesn't really make sense especially if you don't really know whether that code will be there in the next few revisions. In other words, it can be counter-productive. I'm not saying to write sloppy, just don't worry about optimization so much. Hash out your ideas, and get something fun going first. When you get to a point where you have a good sense of the project's direction then you can go back and deal with code legibility and performance.
Refraction comes in really handy, the more you refract the more engine functions you create and the easier it is to change the way it works early on and add better error handling. Anyway I have been continuing to work on my game and have added scrolling with the arrow keys and the ability to use the delete key along with home and end.
[QUOTE=Vbits;25503611]Refraction comes in really handy, the more you refract the more engine functions you create and the easier it is to change the way it works early on and add better error handling. Anyway I have been continuing to work on my game and have added scrolling with the arrow keys and the ability to use the delete key along with home and end.[/QUOTE] You keep using that word. I do not think it means what you think it means. [img]http://mmm-belly-may.typepad.com/.a/6a00e008cbc1de8834013485ef76c7970c-200wi[/img]
[QUOTE=Vbits;25503611]Refraction comes in really handy, the more you refract the more engine functions you create and the easier it is to change the way it works early on and add better error handling. Anyway I have been continuing to work on my game and have added scrolling with the arrow keys and the ability to use the delete key along with home and end.[/QUOTE] I'm trying really hard to understand this post. Refraction is light's direction being changed by a change in medium. I think you are thinking of Modularity, the property of Object Oriented Design that allows you to create objects and systems that 'plug-in' to other objects and systems, in a very simple explanation ( [url]http://en.wikipedia.org/wiki/Module_(programming[/url]) ).
[QUOTE=Kylegar;25503836]I'm trying really hard to understand this post. Refraction is light's direction being changed by a change in medium. I think you are thinking of Modularity, the property of Object Oriented Design that allows you to create objects and systems that 'plug-in' to other objects and systems, in a very simple explanation.[/QUOTE] I think he's thinking of refactoring.
[QUOTE=Vbits;25503611]Refraction comes in really handy, the more you refract the more engine functions you create and the easier it is to change the way it works early on and add better error handling. Anyway I have been continuing to work on my game and have added scrolling with the arrow keys and the ability to use the delete key along with home and end.[/QUOTE] [QUOTE=Vbits;25503611]Refraction comes in really handy, the more you refract[/QUOTE] [QUOTE=Vbits;25503611]Refraction[/QUOTE] :eng99:
I was meaning to say refactoring. Also I added Binary downloads to my game.
A year or so back I wrote my own assembly like language. I just popped open the project and added support for a few more instructions but the instruction set is still really tiny. Currently it parses the .asm file and compiles it into byte-code which is then loaded into the Virtual Machine and executed. At the moment all that's currently output are the accumulator values and the program counter. I've got labels working so you can jump to different parts of the code. Looking forward to implementing branching. There's currently no practical use, just a fun little project. [img_thumb]http://www.moogen.org/blade/dubasm.png[/img_thumb] Here's the current instruction set: [code] enum DUBA_INS : unsigned char { ABA=0, // ABA Add Accumulator's A and B and store into A LDAI, // LDA Load Accumulator A with immediate value LDAM, // LDA Load Accumulator A with value at the follow 16bit address LDBI, // LDB Load Accumulator B with immediate value LDBM, // LDB Load Accumulator B with value at the follow 16bit address LDDI, // LDD Load Double Accumulator D(A:B) LDX, // LDX Load X Register LDY, // LDY Load Y Register LDS, // LDS Load Stack Pointer LDP, // LDP Load Program Counter SAB, // SAB Switch Accumulator's A and B JMP, // JMP Jump to address BNE, // BNE Branch if not equal (z==0) END };[/code] BNE isn't supported yet. Let me know if you want the source... code's pretty meh as it is though.
[QUOTE=bladerunner627;25504078]A year or so back I wrote my own assembly like language. I just popped open the project and added support for a few more instructions but the instruction set is still really tiny. Currently it parses the .asm file and compiles it into byte-code which is then loaded into the Virtual Machine and executed. At the moment all that's currently output are the accumulator values and the program counter. I've got labels working so you can jump to different parts of the code. Looking forward to implementing branching. There's currently no practical use, just a fun little project. [img_thumb]http://www.moogen.org/blade/dubasm.png[/img_thumb] Here's the current instruction set: [code] enum DUBA_INS : unsigned char { ABA=0, // ABA Add Accumulator's A and B and store into A LDAI, // LDA Load Accumulator A with immediate value LDAM, // LDA Load Accumulator A with value at the follow 16bit address LDBI, // LDB Load Accumulator B with immediate value LDBM, // LDB Load Accumulator B with value at the follow 16bit address LDDI, // LDD Load Double Accumulator D(A:B) LDX, // LDX Load X Register LDY, // LDY Load Y Register LDS, // LDS Load Stack Pointer LDP, // LDP Load Program Counter SAB, // SAB Switch Accumulator's A and B JMP, // JMP Jump to address BNE, // BNE Branch if not equal (z==0) END };[/code] BNE isn't supported yet. Let me know if you want the source... code's pretty meh as it is though.[/QUOTE] You should totally add IO support, and let the program interact with the console window via IO.
[QUOTE=Hitachi;25504217]You should totally add IO support, and let the program interact with the console window via IO.[/QUOTE] Yeah I'm not sure how I want to go about that I still haven't implemented instructions that pertain to the virtual memory which will be needed to grab strings from the console. Oh! One other nifty thing, the byte-code shares the same memory space as the stack, accumulators, etc... so once those instructions are added you'll be able to write self modifying code :)
[QUOTE=bladerunner627;25504271]Yeah I'm not sure how I want to go about that I still haven't implemented instructions that pertain to the virtual memory which will be needed to grab strings from the console. [/QUOTE] Why? You could give the console screen the IO address of (for example) 42, then OUT commands to it and IN results. Example [code] OUT 42, 1 // select function 1, could be move cursor (2 parameters) OUT 42, 4 // x position OUT 42, 4 // y position OUT 42, 2 // select function 2, could be put char (1 param) OUT 42, 'A' // put the A character at (4,4) OUT 42, 3 // select function 3, could be read char IN 42, A // read result into register A [/code]
Sorry, you need to Log In to post a reply to this thread.