[QUOTE=Ohfoohy;46614972]So I've been super busy with shooting/editing a short film for a final and I won't have time to catch up on my Java work before the semester is over. Would anyone here be willing to do my remaining assignments? It's a beginner class, so if you know Java already it should only take you a short while to complete them. I'm willing to pay. PM me if you're interested.[/QUOTE]
Are you going to school to learn something or just to pass your time? You're gonna have a hard time later if you just cheat your way trough.
Hi friends!
My dad has an excel file, full of data noting the (month/year) of a gas purchase, as well as the Miles Per Gallon for his truck. (there's other data in there such as l/100km, distance, gas purchased, etc.)
He wants some kind of graph generated so that the X-axis is for January to December. he then wants each year of readings on a separate line drawn on the graph. Unfortunately, there's incomplete information such that some months are missing (didnt fill up on gas then) or more than one fill a month.
I was thinking of using gnuplot in windows (since hes a windows dood) and some kind of batch program so he just runs it and it generates a graph.
Is there any way I can make this easier on me? I'm not too familiar with gnuplot and it's going to be torture to try and get the graphs the way he wants them :P
Excel has built-in shit for that.
Can't Excel chart data on its own?
Or you can do it in BASIC.
Honestly there are a ton of options for making a graph.
If someone can shed me some light on implicit & explicit conversions it would be nice, here's my setup.
I have a "Component" base class, and two classes "SpriteRenderer" & "Transform" that inherits from it because they are components.
I have a "GameObject" class that contains a list of components. Because of that, I added my own "AddComponent<T>()" function with the checking to see if the type "T" is indeed a valid Component (type that inherits from Component).
However "AddComponent<T>()" also returns the component itself, but since it returns a "Component", this:
[CODE]SpriteRenderer spriteRenderer = AddComponent<SpriteRenderer>();[/CODE]
Does not work, and I must do this:
[CODE]SpriteRenderer spriteRenderer = (SpriteRenderer)AddComponent<SpriteRenderer>();[/CODE]
Notice the cast, so because of that, I heard of the magical world of implicit & explicit conversions, so I got my hands on it, and added the following to the "Transform" class:
[CODE]public static implicit operator Transform(Component c)
{
return (Transform)c;
}[/CODE]
And I did the same with my SpriteRenderer class, however, it doesn't work and returns me an "user-definied conversions to or from a base class are not allowed"
So I tried changing the conversion type to explicit, but it returns me the same error.
So either I definetly don't get implicit & explicit conversions, or my returning value from "AddComponent<T>()" is messed up in some way, just in case, here's the "AddComponent<T>()" code:
[CODE]public Component AddComponent<T>() where T : Component, new()
{
T newComp = new T();
newComp.gameObject = this;
_components.Add(newComp);
newComp.Start();
return (T)newComp;
}[/CODE]
I could obviously stick to the good old manual cast but it's kind of a hassle after a while, and Unity handles that pretty well.
If anyone can give me a hint at this it would be awesome.
[QUOTE=Fleskhjerta;46616195]If someone can shed me some light on implicit & explicit conversions it would be nice, here's my setup.
I have a "Component" base class, and two classes "SpriteRenderer" & "Transform" that inherits from it because they are components.
I have a "GameObject" class that contains a list of components. Because of that, I added my own "AddComponent<T>()" function with the checking to see if the type "T" is indeed a valid Component (type that inherits from Component).
However "AddComponent<T>()" also returns the component itself, but since it returns a "Component", this:
[CODE]SpriteRenderer spriteRenderer = AddComponent<SpriteRenderer>();[/CODE]
Does not work, and I must do this:
[CODE]SpriteRenderer spriteRenderer = (SpriteRenderer)AddComponent<SpriteRenderer>();[/CODE]
Notice the cast, so because of that, I heard of the magical world of implicit & explicit conversions, so I got my hands on it, and added the following to the "Transform" class:
[CODE]public static implicit operator Transform(Component c)
{
return (Transform)c;
}[/CODE]
And I did the same with my SpriteRenderer class, however, it doesn't work and returns me an "user-definied conversions to or from a base class are not allowed"
So I tried changing the conversion type to explicit, but it returns me the same error.
So either I definetly don't get implicit & explicit conversions, or my returning value from "AddComponent<T>()" is messed up in some way, just in case, here's the "AddComponent<T>()" code:
[CODE]public Component AddComponent<T>() where T : Component, new()
{
T newComp = new T();
newComp.gameObject = this;
_components.Add(newComp);
newComp.Start();
return (T)newComp;
}[/CODE]
I could obviously stick to the good old manual cast but it's kind of a hassle after a while, and Unity handles that pretty well.
If anyone can give me a hint at this it would be awesome.[/QUOTE]
I might be wrong with this, but can you not change the return type of your function to type T?
i.e
[code]public T AddComponent<T>() where T : Component, new() { /*stuff */ }[/code]
[QUOTE=BackwardSpy;46616389]I might be wrong with this, but can you not change the return type of your function to type T?
i.e
[code]public T AddComponent<T>() where T : Component, new() { /*stuff * }[/code][/QUOTE]
Oh my god I feel stupid now, that also removes all my recasting inside the methods, thanks a lot I didn't know about that.
dumb question, but in terms of an array is index interchangeable with subscript?
yes
Hello, new to programming. I got the book Jumping into C++, and it suggests using Code::Blocks as an IDE/compiler, but trying to download it with Chrome and it's kicking back an error saying the setup file is malicious. Is it safe to use or even a good choice?
[QUOTE=Smallheart;46621001]Hello, new to programming. I got the book Jumping into C++, and it suggests using Code::Blocks as an IDE/compiler, but trying to download it with Chrome and it's kicking back an error saying the setup file is malicious. Is it safe to use or even a good choice?[/QUOTE]
Yes totally safe; not sure if you've got some kind of antivirus going on but I can promise you code::blocks is totally safe, and a pretty good IDE.
[QUOTE=proboardslol;46621117]Yes totally safe; not sure if you've got some kind of antivirus going on but I can promise you code::blocks is totally safe, and a pretty good IDE.[/QUOTE]
I have Mcafee and Malwarebytes but it looked like Chrome itself was blocking it for some reason, because I downloaded it w/ IE and it worked just fine. Either way, stoked to get started. Thanks for the info!
[QUOTE=Smallheart;46621135]I have Mcafee and Malwarebytes but it looked like Chrome itself was blocking it for some reason, because I downloaded it w/ IE and it worked just fine. Either way, stoked to get started. Thanks for the info![/QUOTE]
I've been programming for a while but I just started C++ with code::blocks as well. You can PM me if you have any questions
[QUOTE=proboardslol;46621143]I've been programming for a while but I just started C++ with code::blocks as well. You can PM me if you have any questions[/QUOTE]
Thanks! I'll more than likely be doing that haha.
Hey guys! I could really use some help with an address book program I've been struggling on for days now. I'm working with a doubly linked list in C. I'm trying to add nodes into the list at user-entered positions, starting with position 0. The positions will not be entered out of range. (no inserts at position 1 before something at position 0 etc.) The positions can be repeated though: inserting the new node in the position before the previous position occupant. (for example: if position 1 has x, and new node is inserted at position 1 with y, position 1 now has y and position 2 has x)
I need to take the user entered position number and retrieve the current person in that position, but I can't quite get it right. Also, I have included my insert function if you wanted to take a look at that as well because it isn't working properly either. Thanks for any help!
addressbook.h excerpt:
[code]
typedef struct person Person;
struct person {
char lastName[255];
char firstName[255];
char email[255];
char phoneNumber[255];
Person *pNext;
Person *pPrev;
};
[/code]
addressbook.c excerpt:
[code]
#include "addressbook.h"
Person * InsertPerson(Person * pPersonCur) {
Person * pPersonNew;
/* data gathered for CreatePerson() function here */
pPersonNew = CreatePerson(pLastName, pFirstName, pEmail, pPhoneNumber);
if (pPersonCur)
{
pPersonNew->pNext = pPersonCur;
pPersonNew->pPrev = pPersonCur->pPrev;
pPersonCur->pPrev = pPersonNew;
if (pPersonNew->pPrev)
pPersonNew->pPrev->pNext = pPersonNew;
} else
{
pPersonNew->pPrev = pFirst;
pPersonNew->pNext = NULL;
if (pFirst)
pFirst->pNext = pPersonNew;
}
return (pPersonNew);
}
[/code]
main.c excerpt:
[code]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "addressbook.h"
Person *pFirst; /* First name in list */
int main(void) {
Person *pPersonCur = NULL; /* current Person */
int bDone = 0, position = 0, counter = 0;
pFirst = NULL;
printf("Ready\n");
while (!bDone) {
char input = getchar();
switch (input) {
case 'a':
counter = 0;
scanf("%d", &position); /* Where desired position (such as 0, 1, 2) is entered */
if (position == 0) {
if (pFirst) {
if (pFirst->pNext) {
pPersonCur = pFirst->pNext;
}
} else {
pPersonCur = pFirst;
}
} else {
pPersonCur = pFirst->pNext;
while (counter < position) {
pPersonCur = pPersonCur->pNext;
counter++;
}
}
InsertPerson(pPersonCur); /* Takes in person at desired position, return value is new inserted person */
break;
/* Some other cases here */
case 'q':
bDone = 1;
break;
}
}
/* Rest of code */
[/code]
Anybody know any C libraries which will allow me to generate no-alias square tones of a certain frequency? (2400hz and 1200hz to be exact)
[QUOTE=NixNax123;46614782]Alright, this grid thing is way too much trouble than it's worth. Scrapping this.[/QUOTE]
I must admit, I have trouble comprehending how you can implement a full quadtree but not a (comparatively simpler) grid :rolleyes:
[QUOTE=Tommyx50;46624827]I must admit, I have trouble comprehending how you can implement a full quadtree but not a (comparatively simpler) grid :rolleyes:[/QUOTE]
I implemented the grid and the class completely, but I can't make the entities work with it.
[QUOTE=NixNax123;46625268]I implemented the grid and the class completely, but I can't make the entities work with it.[/QUOTE]
What was the problem you were having with it again?
Also OOP question - what is best practice in regards to calling public member functions of an object inside of another public member function? Is this bad practice/style? I know private member functions are good as helper functions etc but I heard something about keeping the functions in an object as decoupled as possible
-snip, nevermind--
Whatcollection/array structures in C# are closest to Lua tables?
[QUOTE=aurum481;46627977]Whatcollection/array structures in C# are closest to Lua tables?[/QUOTE]
Dictionaries or Hash array/tables.
A hashtable or a dictionary probably
[editline]3rd December 2014[/editline]
motherfucker
- snip -
[QUOTE=killerteacup;46626286]What was the problem you were having with it again?
[/QUOTE]
I couldn't figure out how to add the entities and clear the grid every iteration of the game loop.
[QUOTE=NixNax123;46629218]I couldn't figure out how to add the entities and clear the grid every iteration of the game loop.[/QUOTE]
How? Just add the clear at the start of your game loop?
Is there a way to set an array size to a user defined size? I see that its possible to do something like
[code]
int size;
cout << "Enter the size: ";
cin >> size;
int *array = new int[size];
[/code]
but I am unsure how I can use that size through the rest of my functions if I am using it in main. Right now I just have an array set in global variables and it just has a set size of 10.
[QUOTE=Tommyx50;46629438]How? Just add the clear at the start of your game loop?[/QUOTE]
This is what I'm trying:
[code]
@Override
public void show() {
...
// reset removal list
entsToBeRemoved.clear();
// update entities and check for removal
for (Entity e : entities) {
e.update(dt);
if (e.toBeRemoved()) {
entsToBeRemoved.add(e);
}
e.draw();
}
// draw player last so bullets appear to come out of player (not from center)
player.update(dt);
player.draw();
// clear grid
grid.clear();
// re-fill grid
for (Entity e : entities) {
grid.addEntity(e);
}
// check for collisions
for (Entity e : entities) {
e.detectCollisions(dt);
}
// check if player has no health
if (player.toBeRemoved()) {
player.handleRemoval();
}
for (Entity e : entsToBeRemoved) {
if (e instanceof EnemyShipEntity) {
numEnemies--;
}
e.handleRemoval();
entities.remove(e);
}
...
}[/code] Collision is not working, and bullets are just disappearing soon after they leave my player sprite.
[QUOTE=Gubbygub;46629524]Is there a way to set an array size to a user defined size? I see that its possible to do something like
[code]
int size;
cout << "Enter the size: ";
cin >> size;
int *array = new int[size];
[/code]
but I am unsure how I can use that size through the rest of my functions if I am using it in main. Right now I just have an array set in global variables and it just has a set size of 10.[/QUOTE]
Well you could give all of your functions an extra argument to pass the size of the array to them.
Alternatively you could do something like
[cpp]
struct sizedarray
{
void * buffer;
size_t buffersize;
};
myFunction(sizedarray &mysizedarray);
[/cpp]
Instead of creating custom data structures like above, you're probably better off using an std::vector [url]http://www.cplusplus.com/reference/vector/vector/[/url]
Sorry, you need to Log In to post a reply to this thread.