I-War 2, EOC, 2-D
5 years 3 months ago #19456
by Chessking
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
I-War 2, EOC, 2-D was created by Chessking
I decided to make my own thread for the two dimensional version of Independence War. This will help me to keep working on it, and will be a place that I can ask for help from you guys.
For those who did not read the first post about this project, here is a link to a program showing several assets that I am making: https://www.khanacademy.org/computer-programming/spin-off-of-project-ad-design/5492974005256192 .
It's not much, but I am still working on it, and I have more in other places.
Right now I have been learning Perlin noise, and would like to use it to make planets for the game. My prototype planets are here . However, Processing JS cannot process the noise fast enough for planets over forty pixels wide, or for many planets. I can scale them larger, but then they have jagged edges. Ideas for fixing this are storing the values of the pixels in arrays, but it would take as long to draw them from the array as normal, I think. The other idea is to make my own algorithm that Processing JS can process faster than the built in noise() function. Another possibility is that my computer is the problem. Any ideas?
For those who did not read the first post about this project, here is a link to a program showing several assets that I am making: https://www.khanacademy.org/computer-programming/spin-off-of-project-ad-design/5492974005256192 .
It's not much, but I am still working on it, and I have more in other places.
Right now I have been learning Perlin noise, and would like to use it to make planets for the game. My prototype planets are here . However, Processing JS cannot process the noise fast enough for planets over forty pixels wide, or for many planets. I can scale them larger, but then they have jagged edges. Ideas for fixing this are storing the values of the pixels in arrays, but it would take as long to draw them from the array as normal, I think. The other idea is to make my own algorithm that Processing JS can process faster than the built in noise() function. Another possibility is that my computer is the problem. Any ideas?
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Please Log in or Create an account to join the conversation.
5 years 3 months ago #19471
by Chessking
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Replied by Chessking on topic I-War 2, EOC, 2-D
The problem is drawing so many individual points. At max, I would require 422,500 individual points to be drawn if I were to generate backgrounds with noise. Apparently other applications use noise differently, because I hear that noise can handle jobs like this with less memory usage than if an image were used. Anyways, I think I will have to go with some boring, plain colored planets.
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Please Log in or Create an account to join the conversation.
4 years 11 months ago #19856
by Chessking
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Replied by Chessking on topic I-War 2, EOC, 2-D
I have suddenly started working on this again, even though my first priority program isn't done yet. Her's why:
I had been working on movement functions, but I was doing it all wrong. I was trying to calculate the movement vector (to be added to the players position, introducing motion) by testing if the angle of rotation was in a certain area and a certain key was being pressed, and then adding a value to the vector. For example:
I never got this code to run correctly, so I set out to learn about PVectors, forces, and angular movement.
Since I started my trigonometry class this year (the first section is review since I did it in Pre-Calculus last year) trigonometry has been at the front of my mind. I suddenly realized that the terminal ray on a unit circle is similar to a vector, and that the x and y distances of the new point are functions of the angle. Here's the new code:
Even as I wrote the original code, I knew these trigonometric identities, but I was not able to associate the problem with its trigonometric solution, since I had done little work with trigonometry before. However, I had used the atan2() function to turn a vector into an angle measure, so I wasn't far away.
There is another benefit to the new system also. Under the old system, the maximum magnitude of the direction vector was (1, 1) or sqrt(8 )/2. Using the correct form, the maximum magnitude is (sqrt(2)/2, sqrt(2)/2), or 1. This prevents the ship from covering more space at an angle to the axes then when it is going along an axis.
Anyways, the point is, I have straitened out some simple mistakes that were preventing this update, and now have a working 2-d space flight simulator .
Also, I just learned how to use createGraphics, which allows me to use the 3-d functionalities build into processing.js. Expect decent, low cost planets.
I had been working on movement functions, but I was doing it all wrong. I was trying to calculate the movement vector (to be added to the players position, introducing motion) by testing if the angle of rotation was in a certain area and a certain key was being pressed, and then adding a value to the vector. For example:
if(keyIsPressed && keyCode = RIGHT) {
rotation+=1;
if(rotation >= 0 && rotation < 45) {
direction.x+=1/45;
}else if(rotation >= 45 && rotation < 90) {
direction.y-=1/45;
}//and so on.
}
I never got this code to run correctly, so I set out to learn about PVectors, forces, and angular movement.
Since I started my trigonometry class this year (the first section is review since I did it in Pre-Calculus last year) trigonometry has been at the front of my mind. I suddenly realized that the terminal ray on a unit circle is similar to a vector, and that the x and y distances of the new point are functions of the angle. Here's the new code:
if(keyIsPressed && keyCode = right) {
rotation+=1;
direction.x = sin(rotation);
direction.y = cos(rotation);
}
Even as I wrote the original code, I knew these trigonometric identities, but I was not able to associate the problem with its trigonometric solution, since I had done little work with trigonometry before. However, I had used the atan2() function to turn a vector into an angle measure, so I wasn't far away.
There is another benefit to the new system also. Under the old system, the maximum magnitude of the direction vector was (1, 1) or sqrt(8 )/2. Using the correct form, the maximum magnitude is (sqrt(2)/2, sqrt(2)/2), or 1. This prevents the ship from covering more space at an angle to the axes then when it is going along an axis.
Anyways, the point is, I have straitened out some simple mistakes that were preventing this update, and now have a working 2-d space flight simulator .
Also, I just learned how to use createGraphics, which allows me to use the 3-d functionalities build into processing.js. Expect decent, low cost planets.
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Please Log in or Create an account to join the conversation.
- schmatzler
- Offline
- Site Admin
- Hey Clay? I'm back.
4 years 11 months ago #19859
by schmatzler
Space. The final frontier.
Replied by schmatzler on topic I-War 2, EOC, 2-D
I don't have any idea about what you're doing there, but it feels like an old asteroids game. So I guess you got the mechanics just right
Space. The final frontier.
Please Log in or Create an account to join the conversation.
4 years 11 months ago #19862
by Chessking
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Replied by Chessking on topic I-War 2, EOC, 2-D
The lessons I have been doing were preparing me for building an asteroids game. So far I would say it has Newtonian flight. I am working on collisions now.
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Please Log in or Create an account to join the conversation.
4 years 10 months ago #19899
by Chessking
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Replied by Chessking on topic I-War 2, EOC, 2-D
I have been learning a lot more about rendering with Javascript, so I am certain I can make procedurally generated planets (and backgrounds, if I can find a working algorithm).
This is one tough navy, boy. They don't give you time off, even for being dead. -Clay
Storm Petrel
Please Log in or Create an account to join the conversation.