Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 458 459 [460] 461 462 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909688 times)

BlindKitty

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6885 on: January 15, 2015, 02:58:52 am »

Oh, thanks. I didn't know MSVS Community was a thing. Though, looking at Mono, I think I'm gonna go with that, at least for the time being.

Don't. Unless you have some cryptic, esoteric reason for doing that, don't. VS is probably the best IDE you can get, period. And surely the best you can get for learning C#. There is no reason to choose Mono over VS I could think of, unless you don't have Windows machine. Also, since .NET stack is gonna go open soon (in a shocking plot twist), there will be even less reason to compile using Mono, too.

As a bonus bit of advice: www.dotnetperls.com is a great page to take a look at when you find some kind of problem during C# adventure. And good luck. :)
Logged
My little roguelike craft-centered game thread. Check it out.

GENERATION 10: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6886 on: January 15, 2015, 03:02:34 am »

So I'm doing this exercise for myself. But I dunno which language muscle to work out.

I'm using c/c++ to put together and append to a data file based on the day's date, and feed information to it:
Code: [Select]
String double.value <variable strings> \newline
String double.value <variable strings> \newline
et cetera

This I can do just fine. The question is, what would be a good language to have read from the file and process the data? PERL? Java? C/C++?

I need to ba able to grab data like largest/average/least of the double value, the total count of each of the first strings, and the totals of each variable string, then output to a text/comma separated file.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6887 on: January 15, 2015, 03:06:12 am »

Yeah, some scripting language would be easier to do that than C++. Python, Perl or even JavaScript, which windows wscript can execute on a local windows box for example, without needing any addons. It's a better choice than VBScript if you're scripting on a Windows machine, because you can bet JavaScript is more portable than VB.

But if there was a huge amount of data to process each time, then implementing it in c/c++ would be more efficient in the long run.
« Last Edit: January 15, 2015, 03:08:31 am by Reelya »
Logged

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6888 on: January 15, 2015, 03:24:19 am »

Wonderful, thanks. I'm already formulating it in PERL as we speak.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6889 on: January 15, 2015, 07:14:29 am »

anyone know their way around setting up a .htaccess file for a server redirect using static/CGI/PHP-5.5? any chance you could direct me to a tutorial or something?
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6890 on: January 18, 2015, 02:14:12 pm »

So, I want to get NumPy and I'm finding the various instructions on the internet a little vague.  I'm not even sure if I'm supposed to install it on my computer in general, or put the NumPy folder in my specific project folder or what.  Apparently setup.py in the NumPy folder is supposed to install it for me but I ran that and nothing visible happened except for a console popping up briefly. Trying to "import numpy" in my python code does not work, so I assume it is not installed.

What's the simplest way to do this?  Also if I have to install this thing how will anything I write using it work on someone else's computer?
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Uristides

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6891 on: January 18, 2015, 02:50:50 pm »

So, I want to get NumPy and I'm finding the various instructions on the internet a little vague.  I'm not even sure if I'm supposed to install it on my computer in general, or put the NumPy folder in my specific project folder or what.  Apparently setup.py in the NumPy folder is supposed to install it for me but I ran that and nothing visible happened except for a console popping up briefly. Trying to "import numpy" in my python code does not work, so I assume it is not installed.

What's the simplest way to do this?  Also if I have to install this thing how will anything I write using it work on someone else's computer?
Did you try invoking it from a console and looking what exactly setup.py prints? Anyway, it's been ages since I used that on windows, but I'm pretty sure there was an executable installer or at least a python egg.

Now the second one is a good question. I'm pretty sure there's ways to pack your script and everything it needs to run on a single, compact, executable, but I myself never touched them, so yeah, the simplest way is making everybody who wants to run your stuff get numpy too.
Logged

Hugehead

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6892 on: January 18, 2015, 03:26:32 pm »

So, I want to get NumPy and I'm finding the various instructions on the internet a little vague.  I'm not even sure if I'm supposed to install it on my computer in general, or put the NumPy folder in my specific project folder or what.  Apparently setup.py in the NumPy folder is supposed to install it for me but I ran that and nothing visible happened except for a console popping up briefly. Trying to "import numpy" in my python code does not work, so I assume it is not installed.

What's the simplest way to do this?  Also if I have to install this thing how will anything I write using it work on someone else's computer?
The simplest way to install any package for Python is using the pip package manager, if you installed Python 2.7.9 or Python 3.4 or later you already have it, if not there are instructions here on how to install it.

After you have pip you can just run
Code: [Select]
pip install numpyin your shell and it will install the latest version of numpy and any dependencies globally, usable by any script you use on your computer. (I think there are sandboxes available but I'm not sure, you probably don't want numpy in one of those anyway.) After that you can upgrade it to the latest version anytime one comes out by running
Code: [Select]
pip install --upgrade numpy
The full documentation for pip is here, it's a really useful tool!

EDIT: pip may not actually work for numpy, it seems like it's trying to build from source when I run the command in pip, so you'll probably have to use one of the prebuilt binaries. I don't know which one you need, so you'll need someone else to figure that out for you. pip's great for most packages though!
« Last Edit: January 18, 2015, 03:37:31 pm by Hugehead »
Logged
We're Bay12er's. If there is a bug, we will find it, exploit it, and make a recursive statue out of it. Just look up Planepacked.
When a dwarf enters a martial trance, they become Jedi. Short, drunken Jedi.

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6893 on: January 18, 2015, 08:48:44 pm »

Ok, I got numpy (by googling until a stack overflow answer directed me to the unofficial binaries).  I've also found a python-to-.exe program, no idea if it will work with numpy though as numpy seems to have different versions for every possible combination of python and os version.

There's a fairly logical stopping point where I can test if the numpy code is working properly.  I'll package the program there, then send it to some friends who have different OSs then me.  That way I'll know how if it works before I commit to writing a lot of numpy code.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6894 on: January 21, 2015, 12:57:35 pm »

I'm coding some tetris thing in C++ as practice, and I thought it was going well, until I tried to compile (hadn't compiled yet since there was nothing to look at anyway. Still isn't).
However, it throws a lot of errors that I don't even see the cause of. I'm building with MSVS, if that's any help. The first error is "syntax error : missing ';' before '*'" on line 33, which is just "block *tet = nullptr;". I don't see anything wrong with that.
(There's probably some legitimate errors with me doing stuff wrong that intellisense or w/e hasn't picked up, and the code is probably awful in places but I'm trying to do this without tutorials)
Errors:
Code: [Select]
1>------ Build started: Project: tetris, Configuration: Debug Win32 ------
1>  tetris.cpp
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(33): error C2143: syntax error : missing ';' before '*'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(34): error C2143: syntax error : missing ';' before '*'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(34): error C2086: 'int block' : redefinition
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(33) : see declaration of 'block'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(39): error C2065: 'clear_box' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(39): error C2446: '>' : no conversion from 'int (*)[10]' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(39): error C2040: '>' : 'int' differs in levels of indirection from 'int [25][10]'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(60): error C2536: 'block::block::piece' : cannot specify explicit initializer for arrays
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(60) : see declaration of 'block::piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(87): error C3861: 'create_tetromino': identifier not found
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(98): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'int *'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(129): error C2143: syntax error : missing ';' before '*'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(129): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(129): error C2086: 'int block' : redefinition
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(33) : see declaration of 'block'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(130): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(131): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(131): error C2061: syntax error : identifier 'block'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(142): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(142): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(142): error C2780: 'void copy_array(int [][height],int [][width])' : expects 2 arguments - 1 provided
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(117) : see declaration of 'copy_array'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(143): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(144): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(152): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(152): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(153): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(153): error C2227: left of '->rotateable' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(154): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(155): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(156): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(163): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(163): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(164): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(165): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(156) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(166): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(173): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(173): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(174): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(175): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(166) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(156) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(176): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(183): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(183): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(184): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(185): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(176) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(166) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(156) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(186): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(193): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(193): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(194): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(195): error C2360: initialization of 'piece' is skipped by 'case' label
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(186) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(176) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(166) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(156) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(145) : see declaration of 'piece'
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(196): error C2374: 'piece' : redefinition; multiple initialization
1>          c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(135) : see declaration of 'piece'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(203): error C2065: 'newtet' : undeclared identifier
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(203): error C2227: left of '->piece' must point to class/struct/union/generic type
1>          type is 'unknown-type'
1>c:\users\operand\_documents\ceeples\tetrisiguesstoo\tetris\tetris\tetris.cpp(204): error C2065: 'newtet' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code:
Code: [Select]
/*
Some dumb tetris game, for learning purposes. v0.1
By Miauw/Operand.
I have no idea if this works on Linux, but it should, if you're willing to make it work.
*/
#include <curses.h>
#include <stdio.h>
#include <string.h>
#include <iostream>

//defines
#define TERM_HEIGHT 30
#define TERM_WIDTH 20
#define FIELD_HEIGHT 25
#define FIELD_WIDTH 10
#define ORIGIN_X 2
#define ORIGIN_Y 2
char possible_tets[7] = { 'i', 'o', 't', 'l', 'j', 'z', 's' }; //b-but this isn't a define ;~;

//function definitions
void handle_input();
void handle_blocks();
void clear_field();
void rotate(int direction);
void copy_array(int from[][5], int to[][5]);

//global variable definitions and initialization
long tick = 0;
char input = ' ';
int fall_delay = 40;
int lines_cleared;
int field[FIELD_HEIGHT][FIELD_WIDTH];
block *tet = nullptr;
block * queuedtet = nullptr;
WINDOW *field_window;

int main()
{
clear_box<FIELD_HEIGHT, FIELD_WIDTH>(field);
initscr();
resize_term(TERM_WIDTH, TERM_HEIGHT);
resize_window(stdscr, TERM_WIDTH, TERM_HEIGHT);
cbreak();

while (true)
{
handle_input();
if (tick % fall_delay == 0)
{
handle_blocks();
}
tick++;
refresh();
_sleep(40);
}
}

struct block
{
int piece[5][5] = { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } };
bool rotateable = true;
};

void handle_input()
{
input = getch();
switch(input)
{
case 'q':
rotate(1);
break;
case 'e':
rotate(-1);
break;
case 'w': //debug
delete tet;
tet = nullptr;
break;
}
}

void handle_blocks()
{
if (tet == nullptr)
{
tet = queuedtet;
queuedtet = create_tetromino(possible_tets[rand() % 6]);
}
}

void rotate(int direction)
{
int newpiece[5][5];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
newpiece[i][j] = tet->piece[(direction ? -1 : 1) * (2 - i)][(direction ? -1 : 1) * (2 - j)];
}
}

}

template <int height, int width> //thank you based templates
void clear_box(int inputarr[height][width])
{
for (int i = 0; i < height - 1; i++)
{
for (int j = 0; j < width - 1; i++)
{
inputarr[i][j] = 0;
}
}
}

template <int height, int width>
void copy_array(int from[][height], int to[][width])
{
for (int i = 0; i < height - 1; i++)
{
for (int j = 0; j < width - 1; j++)
{
to[i][j] = from[i][j];
}
}
}

//at the bottom because it's obnoxious
block * create_tetromino(char tettype)
{
block * newtet = new block;
switch (tettype)
{
case 'i':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
case 'o':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 0 },
{ 0, 1, 1, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
newtet->rotateable = false;
return newtet;
case 't':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
case 'j':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 1, 1, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
case 'l':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 0, 0 },
{ 0, 0, 1, 1, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
case 's':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0, 1, 1, 0 },
{ 0, 1, 1, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
case 'z':
int piece[5][5] = {
{ 0, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 0 },
{ 0, 0, 1, 1, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
copy_array<5, 5>(piece, newtet->piece);
return newtet;
}
}
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6895 on: January 21, 2015, 01:04:28 pm »

It appears you don't have the block struct defined before first call, and that's why it's asking for a ';' before the *tet on line 33.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6896 on: January 21, 2015, 01:06:10 pm »

Oh, goddamn >.<
Thanks for the help.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6897 on: January 21, 2015, 01:08:59 pm »

Oh, goddamn >.<
Thanks for the help.

S'what we're here for :D I've made many a stupid mistake like that. The difference is, I bang my head against the wall for hours and never ask for help.

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6898 on: January 21, 2015, 01:09:12 pm »

When you get these two errors together in VC++:
Quote
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

It means that it doesn't know what the type you've used is, and has tried to use the type as the variable name (in old C "default-int" means if you left the type off it would assume "int" type).

Either move your "struct block" before the variables, or put in a forward declaration:
Code: [Select]
struct block;
C++ likes forward declarations a lot. A forward declaration allows any code that doesn't need to know the internals of the type to compile, so you can declare pointer variables but not instance variables or dereference said pointers, until the actual definition of the type is encountered.
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6899 on: January 21, 2015, 01:28:25 pm »

Would be way more convenient if the code thingy here would show numbers.

Okay then.

Line 33: You have not yet declared what a block is.
Line 34: Same.
This is weird. WTF is this. "missing type specifier - int assumed." It just fucking assumes that block is an int. I just...
what.

Line 39: Have not yet declared what clear_box is. Seemingly still resolves it later. And then thinks that your "int inputarr[height][width]" is just an int.
I have no idea. I genuinely have no idea. I don't do template code, and I have absolutely no idea if this should even theoretically be a correct way to do them.

Line 60: Googling the problem reveals that you are using a compiler that doesn't fully conform to C++11. Either change compilers or don't do explicit initializers for arrays.

Line 87: create_tetromino hasn't been declared yet.

Line 98: Assuming that anything lying around is an int...ARGHBLA*foam starts spewing from mouth*
Line 129, 130: SADWFFASFDSDSAVCZCVVSVEAGEWA
ARDFSDGS

DSGEGEWX
zGSZEz
W̵̡̧̲͙͕̜̬̘͈̬͍̩̺̗͜͝H̢̠̖̰̙̦͚̝͉͙͔̮͖̙͎̕͜A̶͙͕͖͕̬ͅṰ̡̗̣͢͞͡



So most of these seem to stem from block not being declared yet.
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.
Pages: 1 ... 458 459 [460] 461 462 ... 796