Home › Forums › I-War Development Section › Developer’s Corner › Preferred developing language
- This topic has 22 replies, 3 voices, and was last updated 7 years, 8 months ago by Chessking.
-
AuthorPosts
-
3. March 2017 at 7:42 #18484IronyManParticipant
Okay, maybe this is a little silly; I know there are only four or so other people active on this forum. But I’ve been planning a project for a long time and I’m wondering what language to program it in. It’s a 2-D top-down rpg sort of thing in space, with an open and mostly transition-free universe and the ability to move independently as a character (a la Star Citizen) outside of spaceships and through stations, etc. Instead of being set in stone, ships and other vehicles will be haphazard combinations of skeletons and modules. I’m starting to prototype the movement system in Processing.js just because that’s the language/library I’m most comfortable with.
I’m trying to decide between Python, C++, and Java for the final project. What do you guys prefer? What do you suppose would fit it best? Optimization and rendering won’t need to be amazing; I’m doing pretty simple graphics. I know a little bit of Python, but none of the others. This project is my first foray into serious (semi-serious?) development; pretty simple, but with enough complexity to force me to work hard at it.
Sorry for my irrelevant rambling. Thoughts?
3. March 2017 at 9:22 #18485IronDukeParticipantJust use Unity. It has C# and a modified form of Javascript. It’s got a ton of incredibly handy tools for 2D games. I’d say it downright excels at them. I made a fairly basic but incredibly fun game that’s sorta like a Ring Runner game in one month using Unity.
Super busy, can’t help more, but I’m just tossing that in there for ya. π–IronDuke
I-War 2 Discord: https://discord.gg/RWaabWB
Very little about the game is not known to me. Any questions you got, throw them at me. π7. March 2017 at 1:07 #18487ChesskingParticipantI say you should stick to Processing.js. It is quite capable of handling 2-D games, and makes it fairly easy to add to websites. Who wants to download and install a 2-D game, when it could run instantly in their browser? And browser game websites like Kongregate would be happy to host it, and you would get some ad revenue.
Of course, Unity games can run in a browser as well.
Instead of being set in stone, ships and other vehicles will be haphazard combinations of skeletons and modules.
pretty simple, but with enough complexity to force me to work hard at it.
Whatever you say… π
This is one tough navy, boy. They donβt give you time off, even for being dead. -Clay
Storm Petrel
8. March 2017 at 19:18 #18497IronyManParticipantThanks for the suggestions. I want to learn to code directly; if this were a more serious project I’d consider using Unity or some other advanced environment, but I need to improve my basic skills first.
Chessking, I may just take the JS prototype as far as I can. I’m working out the module system on Khan Academy; flight and independent vehicles already work.
The difficulty is in writing my own physics engine from scratch… that’s one of the main reasons I’m attempting this. I get to teach myself trigonometry. Fun! π
8. March 2017 at 21:35 #18499ChesskingParticipantIf you need a few tips on the Physics engine, I have already created one with Processing.js on Khan Academy.
The code is outdated compared to what I have now, but the basic OOP and trigonometry is correct.
This is one tough navy, boy. They donβt give you time off, even for being dead. -Clay
Storm Petrel
8. March 2017 at 22:59 #18502IronDukeParticipant[quote=”IronyMan” post=20538]I’d consider using Unity or some other advanced environment… need to improve my basic skills first… writing my own physics engine from scratch…[/quote]
lolwut? That’s way harder than using Unity. With Unity, it’s practically drag-and-drop. The only coding you need is applying forces for thrusters and such, which is one line.
To each his own, of course, but I really think you’re overcomplicating things. XD–IronDuke
I-War 2 Discord: https://discord.gg/RWaabWB
Very little about the game is not known to me. Any questions you got, throw them at me. π9. March 2017 at 4:16 #18504IronyManParticipantI understand that it’s simpler and easier. I’m teaching myself the basics of programming, that is, what’s underneath those boxes in Unity that you drag around. I want to learn the conceptual material behind it all. :side:
Do you know what I mean?
9. March 2017 at 4:17 #18506IronDukeParticipantAh, I understand. Go to it then, and more power to you! o7
–IronDuke
I-War 2 Discord: https://discord.gg/RWaabWB
Very little about the game is not known to me. Any questions you got, throw them at me. π9. March 2017 at 19:53 #18518IronyManParticipant[quote=”Chessking” post=20539]If you need a few tips on the Physics engine, I have already created one with Processing.js on Khan Academy.[/quote]
Heh, it’s neater and smoother than mine. :unsure:
I’m having some difficulty with my rotate to mouse function; when the angle of the ship resets to zero the ship tries to turn the other way to get to the mouse. I think it’s a result of my clumsy coding. I’ll need to write an exception to account for zero.
Or maybe rewrite the whole thing to rely on absolute differences instead of the concrete angles… :blink:
In the meantime, I need to finish my Alg 2 course. :angry: Maybe when I actually know how to do basic math I’ll be able to solve simple problems like this easily.
9. March 2017 at 21:38 #18520ChesskingParticipantIs your project on Khan Academy? I would like to see exactly what you are talking about. I have an idea of what the problem is, but I can’t be sure.
This is one tough navy, boy. They donβt give you time off, even for being dead. -Clay
Storm Petrel
10. March 2017 at 2:42 #18522IronyManParticipantHere it is. Still very rough, has a lot of problems. I don’t have much time to work on it.
I tried a couple of solutions, but ended up confusing myself more. If it doesn’t make sense I can explain it here or in the KA comments.
10. March 2017 at 3:46 #18524ChesskingParticipantYour link doesn’t seem to be working, IronyMan. I’m not sure why.
I have been working on EOC 2-D. While playing around with the autopilot approach, I noticed that when coming from a certain direction, (the top right corner, to be exact), a ship would overshoot its target.
The first thing I did to fix this was optimization. I had been manually calculating the stopping distance of the ship using a for loop. During a physics class I took a little while ago, I found a formula that would do the job better. I implemented the formula, and the ship still overshoots. I am as baffled about my problem as you are with yours. π
Edit: I solved my problem! Yay!
This is one tough navy, boy. They donβt give you time off, even for being dead. -Clay
Storm Petrel
10. March 2017 at 7:35 #18528IronyManParticipantLink works for me. π
Here’s a text file with it; paste it all into a new program on Khan.
The controls mimic Starsector; I think they work pretty well. But then, I play Starsector a lot… :unsure:
Hoy, good problem solving! I hope I have as much luck with my issue.
Attachments:10. March 2017 at 23:00 #18537IronyManParticipantHang on, new link.
Should work now. Sorry about that.
I’ve added rotational momentum, and that has further aggravated the issue of mouse control. I think I’ll drop that problem for now, but any input is welcome.
10. March 2017 at 23:54 #18541ChesskingParticipantThe link still doesn’t work for me. Perhaps something in your account settings does not let other people view your programs? I’m not sure. Perhaps if you give me the link to your profile, rather than a specific program, that will work.
I know what your problem is. Here is the code starting at line 172. I added the rotation variable and the two println() statements for debugging purposes.
if (char.inship === true && control.occupied === true) {
char.a = control.a;
var rotation = atan2(mouseY-width/2,mouseX-height/2)-90;
println(rotation);
println(control.a);
if (keys[SHIFT]) {
if (control.a < atan2(mouseY-width/2,mouseX-height/2)-90) { control.a += control.agility; } if (control.a > atan2(mouseY-width/2,mouseX-height/2)-90) {
control.a -= control.agility;
}}
Plug this code into your program and you will see the problem. At the left hand side, the rotation variable switches from 270 to -90, which obviously affects whether control.a is greater than or less than the mouse angle.To solve this, we need to designate an optimal situation. We can do this in the form of an IPO (input, processing, output) chart. The inputs are the ship rotation, and the mouse rotation to the center of the screen. I think the desired output should be the angle between these two angles. When the ship is facing the mouse, the output should be 0. As the mouse moves clockwise around the ship, the angle should increase, reaching 180 behind the ship. As the mouse moves counter-clockwise around the ship, the angle should decrease, reaching -180 behind the ship. The switching point between positive and negative angles should always be behind the ship.
The final stage is the processing stage. How do we get from input to output? First, we define a variable for each input. We already have control.a defined, so lets add
var rotation = atan2(mouseY-height/2,mouseX-width/2);
for the mouse angle.Now, let’s say the ship is rotated 100 degrees, and is facing the pointer. Both input variables will be the same. If we subtract control.a from rotation, the angle will be 0 whenever the ship is facing the pointer.
var rotation = atan2(mouseY-height/2,mouseX-width/2)-control.a;
Now, not only is rotation 0 when the ship is facing the mouse, but the angle increases as the mouse moves clockwise around the ship, and decreases when the mouse moves counterclockwise around the ship, reaching -180 behind the ship. However, the number continues to decrease beyond that point, until it switches to a positive number at the left.To fix this, all we have to do is add 360 to var rotation when rotation is less than -180. At the same time, we should subtract 360 when rotation is greater than 180.
if(rotation >= 180) {
rotation -= 360;
}else if(rotation < -180) { rotation += 360; }
I originally used a while loop instead of an if statement, because the manual rotation of the ship allows control.a to reach values much higher than 180, 360, or even 1000. However, I then discovered this section of code in your program:
if (control.a > 360) {
control.a = 0;
}
This solves the problem if control.a reaches high values, but not if it reaches low values. So I would suggest changing it to this:
if (control.a >= 360) {
control.a = 0;
}
if (control.a < 0) { control.a = 360; }Edit: I forgot to mention, you need this code to utilize the output.
if (keys[SHIFT]) {
if(rotation > 0) {
control.a += control.agility;
}
if(rotation < 0) { control.a -= control.agility; } }Now, everything should be working properly.
For clarity, here is the entire fixed program: program.
I hope this helps!P.S. Because var rotation is larger the further your mouse angle is from the angle of the ship, you could tell the ship to rotate faster or slower as well.
P.P.S. The ship will vibrate around its focal point. This is because var rotation is not being updated when control.a is being updated during the execution stage (the code shown in my edit). The code below fixes the problem, albeit not very efficiently.
if (keys[SHIFT]) {
if(rotation > 0) {
control.a += control.agility;
}
var rotation = atan2(mouseY-height/2,mouseX-width/2)-control.a;
if(rotation >= 180) {
rotation -= 360;
}
if(rotation < -180) { rotation += 360; } if(rotation < 0) { control.a -= control.agility; } }
This is one tough navy, boy. They donβt give you time off, even for being dead. -Clay
Storm Petrel
-
AuthorPosts
- You must be logged in to reply to this topic.