Program/game development

This is a forum for discussing the feasibility of getting emulators, games, or other applications that have had their source released ported to the Dreamcast. Please read the Porting FAQ before starting a topic in this forum!
Post Reply
Dautor
DCEmu Newbie
DCEmu Newbie
Posts: 4
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat Jun 01, 2013 7:43 am
Location: Croatia
Has thanked: 0
Been thanked: 0

Program/game development

Post by Dautor »

I just started creating a simulator in java. It simulates circuits with a lot of premade basic gates and thats only the begining.
I wanted some opinions on how should I organize my code and I need some help with time (ticking and main loop) and with lwjgl.
I want to know how hard would it be to have that you can create your own gates combining other gates and then combining those until you build something nice.
If someone is willing to be sub-dev and help (tell me some things, help with errors and stuff, give ideas) I would be tankful!
Thank you for your understanding, if you want my skype name just pm me.

"Imagination is more important than knowledge." - Albert Einstein

Sry for my bad english!
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 366
Joined: Wed Mar 30, 2011 12:13 pm
Has thanked: 2 times
Been thanked: 0

Re: Program/game development

Post by RyoDC »

So what's the problem?
There's no silver bullet in a program design. You can use some patterns, proved by time (they are even called "desgin patterns", google'em), but there's no thing like a golden solution for all problems that can arise while developing your program.
For simulating logic gates you can use inheritance or composition, just pick up what better suits your needs.
For organizing of code, the only advice I can give, is to divide your program logic and it's visual design, I mean, don't mess in to one pile the presentation logic (like, drawButton api's) and program logic.
Also take a look at liskov principles and some good design books, that covers program architecture, but I don't think that that is something you need right now.
Just write it as it writes, value your decisions, and do some refactoring when you see that you can improve the things.

BTW, as a good book on patterns for beginners I can advice an Eric Freeman's Patterns, it's not bad.
How do I try to build a Dreamcast toolchain:
Image
Dautor
DCEmu Newbie
DCEmu Newbie
Posts: 4
Joined: Sat Jun 01, 2013 7:43 am
Location: Croatia
Has thanked: 0
Been thanked: 0

Re: Program/game development

Post by Dautor »

Ty for answering and helping me a lot, but i still got no idea how to do so you can have infinite gates without typing every 1 of them and how could i create infinite pointers (I mean so you can just put like And1 and itll take output from first and gate (or something like that) so that you dont need to write everything that gate had before it) and i still dont know how can i put so that gates have 1 tick delay :(
Ill ask my friend how to do it if you dont have any good ideas! Btw my program is in java
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 366
Joined: Wed Mar 30, 2011 12:13 pm
Has thanked: 2 times
Been thanked: 0

Re: Program/game development

Post by RyoDC »

>but i still got no idea how to do so you can have infinite gates without typing every 1 of them

You mean, not typing them in the code?

Then the strategy is simple:
1. Create a class that describes your Logic gate as an entity in the memory wth all needed fields, inputs, etc..
2. When user wants to create a new gate, you just allocate a memory for that gate and put it in the some collection, like LinkedList, for example.
3. You'll have some class that would content rendering logic, so when it becomes time to render everything on the screen, you'll just call that function and it will render everything up on screen from that collection.

>(I mean so you can just put like And1 and itll take output from first and gate (or something like that) so that you dont need to write everything that gate had before it)

Do you heard about Data structures? Google'em and read about them.
Especially what the List is.

>and i still dont know how can i put so that gates have 1 tick delay
So you have some simulation metrics. That's good.
Just create a field in a class, describing your AND-Gate, which will be named Delay, and create a get and a set mthod whcih will set the neeeded tick delay for it.
Also, you'll need to write a simultion logic, that will take in account that field and will account it in it's modeling result.
How do I try to build a Dreamcast toolchain:
Image
Dautor
DCEmu Newbie
DCEmu Newbie
Posts: 4
Joined: Sat Jun 01, 2013 7:43 am
Location: Croatia
Has thanked: 0
Been thanked: 0

Re: Program/game development

Post by Dautor »

I make a class called Gate and it has only 1 field called state, which is initialy off and it has getState() and setState() which requiers boolean for input.
Then i have class caled GatesBasic which contains all the basic gates (not, or, nor, and, nand, xor, xnor) and every1 of them can return a boolean value.
And lastly i have class called TFlipFlop which sets its state to negative every time function Flip() is called.
So you mean i should create object for every 1 of them?
I am not so good with object oriented programming so i dont know how can i call a diffrent object every time new gate is called, but i'll try.

Thank you for everything you said, it helped me a lot!

Now im going to try creating that delay!
Dautor
DCEmu Newbie
DCEmu Newbie
Posts: 4
Joined: Sat Jun 01, 2013 7:43 am
Location: Croatia
Has thanked: 0
Been thanked: 0

Re: Program/game development

Post by Dautor »

Good news, it works like a charm :D i changed my gates to voids that only get and set the state, and now i have that memmory, but i only dont know how to make that you dont need to creat every single object of a gate in code to get it :(
And i got something great unintentionaly, object has every single gate so you can change that gate just by calling diferent method :D and later when itll have graphics ill make so you can right click and select a gate to change a type of the gate! :D

Sry for my bad english
Post Reply