Это игра, нужно успеть нажать на кнопку пока она активна, но через она исчезает, когда активна другая(для летней практики в вузе доп. задание).
ребят ну вопрос такой: есть ли какой то процесс в самой форме который всё время запрашивается, не такой как при загрузке, когда один раз пробежит и по нему и всё, а чтобы всё время обновлялось?
Ну вообще я изначально делал в кнопке старт, но тогда я не уверен что во время этого можно будет нажимать другие кнопки, а если можно то как проверить нажата ли кнопка пока идёт время игры(минута даётся на неё).
И ещё как узнать что таймер закончил работу.
#pragma once
#include "ctime"
#include "iostream"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace Летняяпрактика {
/// <summary>
/// Сводка для Form_Game
///
/// Внимание! При изменении имени этого класса необходимо также изменить
/// свойство имени файла ресурсов ("Resource File Name") для средства компиляции управляемого ресурса,
/// связанного со всеми файлами с расширением .resx, от которых зависит данный класс. В противном случае,
/// конструкторы не смогут правильно работать с локализованными
/// ресурсами, сопоставленными данной форме.
/// </summary>
public ref class Form_Game : public System::Windows::Forms::Form
{
public:
Form_Game(void)
{
InitializeComponent();
//
//TODO: добавьте код конструктора
//
}
protected:
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
~Form_Game()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;
private: System::Windows::Forms::Button^ button10;
private: System::Windows::Forms::Button^ button11;
private: System::Windows::Forms::Button^ button12;
private: System::Windows::Forms::Button^ button13;
private: System::Windows::Forms::Button^ button14;
private: System::Windows::Forms::Button^ button15;
private: System::Windows::Forms::Button^ button16;
private: System::Windows::Forms::Button^ button_start;
private: System::Windows::Forms::Button^ button_out;
private: System::Windows::Forms::Timer^ timer_game;
private: System::ComponentModel::IContainer^ components;
private:
/// <summary>
/// Требуется переменная конструктора.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Обязательный метод для поддержки конструктора - не изменяйте
/// содержимое данного метода при помощи редактора кода.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->button10 = (gcnew System::Windows::Forms::Button());
this->button11 = (gcnew System::Windows::Forms::Button());
this->button12 = (gcnew System::Windows::Forms::Button());
this->button13 = (gcnew System::Windows::Forms::Button());
this->button14 = (gcnew System::Windows::Forms::Button());
this->button15 = (gcnew System::Windows::Forms::Button());
this->button16 = (gcnew System::Windows::Forms::Button());
this->button_start = (gcnew System::Windows::Forms::Button());
this->button_out = (gcnew System::Windows::Forms::Button());
this->timer_game = (gcnew System::Windows::Forms::Timer(this->components));
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(57, 71);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 64);
this->button1->TabIndex = 0;
this->button1->UseVisualStyleBackColor = true;
//
// button2
//
this->button2->Location = System::Drawing::Point(166, 71);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 64);
this->button2->TabIndex = 1;
this->button2->UseVisualStyleBackColor = true;
//
// button3
//
this->button3->Location = System::Drawing::Point(276, 71);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 64);
this->button3->TabIndex = 2;
this->button3->UseVisualStyleBackColor = true;
//
// button4
//
this->button4->Location = System::Drawing::Point(382, 71);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 64);
this->button4->TabIndex = 3;
this->button4->UseVisualStyleBackColor = true;
//
// button5
//
this->button5->Location = System::Drawing::Point(57, 153);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 64);
this->button5->TabIndex = 4;
this->button5->UseVisualStyleBackColor = true;
//
// button6
//
this->button6->Location = System::Drawing::Point(166, 153);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 64);
this->button6->TabIndex = 5;
this->button6->UseVisualStyleBackColor = true;
//
// button7
//
this->button7->Location = System::Drawing::Point(276, 153);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 64);
this->button7->TabIndex = 6;
this->button7->UseVisualStyleBackColor = true;
//
// button8
//
this->button8->Location = System::Drawing::Point(382, 153);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(75, 64);
this->button8->TabIndex = 7;
this->button8->UseVisualStyleBackColor = true;
//
// button9
//
this->button9->Location = System::Drawing::Point(57, 243);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(75, 64);
this->button9->TabIndex = 8;
this->button9->UseVisualStyleBackColor = true;
//
// button10
//
this->button10->Location = System::Drawing::Point(166, 243);
this->button10->Name = L"button10";
this->button10->Size = System::Drawing::Size(75, 64);
this->button10->TabIndex = 9;
this->button10->UseVisualStyleBackColor = true;
//
// button11
//
this->button11->Location = System::Drawing::Point(276, 243);
this->button11->Name = L"button11";
this->button11->Size = System::Drawing::Size(75, 64);
this->button11->TabIndex = 10;
this->button11->UseVisualStyleBackColor = true;
//
// button12
//
this->button12->Location = System::Drawing::Point(382, 243);
this->button12->Name = L"button12";
this->button12->Size = System::Drawing::Size(75, 64);
this->button12->TabIndex = 11;
this->button12->UseVisualStyleBackColor = true;
//
// button13
//
this->button13->Location = System::Drawing::Point(57, 335);
this->button13->Name = L"button13";
this->button13->Size = System::Drawing::Size(75, 64);
this->button13->TabIndex = 12;
this->button13->UseVisualStyleBackColor = true;
//
// button14
//
this->button14->Location = System::Drawing::Point(166, 335);
this->button14->Name = L"button14";
this->button14->Size = System::Drawing::Size(75, 64);
this->button14->TabIndex = 13;
this->button14->UseVisualStyleBackColor = true;
//
// button15
//
this->button15->Location = System::Drawing::Point(276, 335);
this->button15->Name = L"button15";
this->button15->Size = System::Drawing::Size(75, 64);
this->button15->TabIndex = 14;
this->button15->UseVisualStyleBackColor = true;
//
// button16
//
this->button16->Location = System::Drawing::Point(382, 335);
this->button16->Name = L"button16";
this->button16->Size = System::Drawing::Size(75, 64);
this->button16->TabIndex = 15;
this->button16->UseVisualStyleBackColor = true;
//
// button_start
//
this->button_start->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->button_start->Location = System::Drawing::Point(-1, -1);
this->button_start->Name = L"button_start";
this->button_start->Size = System::Drawing::Size(133, 40);
this->button_start->TabIndex = 16;
this->button_start->Text = L"Старт!";
this->button_start->UseVisualStyleBackColor = true;
this->button_start->Click += gcnew System::EventHandler(this, &Form_Game::button_start_Click);
//
// button_out
//
this->button_out->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->button_out->Location = System::Drawing::Point(382, -1);
this->button_out->Name = L"button_out";
this->button_out->Size = System::Drawing::Size(133, 40);
this->button_out->TabIndex = 17;
this->button_out->Text = L"Выход!";
this->button_out->UseVisualStyleBackColor = true;
this->button_out->Click += gcnew System::EventHandler(this, &Form_Game::button_out_Click);
//
// timer_game
//
this->timer_game->Interval = 60000;
//
// Form_Game
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(514, 436);
this->Controls->Add(this->button_out);
this->Controls->Add(this->button_start);
this->Controls->Add(this->button16);
this->Controls->Add(this->button15);
this->Controls->Add(this->button14);
this->Controls->Add(this->button13);
this->Controls->Add(this->button12);
this->Controls->Add(this->button11);
this->Controls->Add(this->button10);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form_Game";
this->Text = L"Form_Game";
this->Load += gcnew System::EventHandler(this, &Form_Game::Form_Game_Load);
this->ResumeLayout(false);
}
#pragma endregion
void BtnFalse() {
this->button_out->Enabled = false;
this->button_start->Enabled = true;
this->button1->Enabled = false;
this->button2->Enabled = false;
this->button3->Enabled = false;
this->button4->Enabled = false;
this->button5->Enabled = false;
this->button6->Enabled = false;
this->button7->Enabled = false;
this->button8->Enabled = false;
this->button9->Enabled = false;
this->button10->Enabled = false;
this->button11->Enabled = false;
this->button12->Enabled = false;
this->button13->Enabled = false;
this->button14->Enabled = false;
this->button15->Enabled = false;
this->button16->Enabled = false;
}
private: System::Void Form_Game_Load(System::Object^ sender, System::EventArgs^ e) {
BtnFalse();
}
private: System::Void button_start_Click(System::Object^ sender, System::EventArgs^ e) {
this->button_out->Enabled = true;
this->button_start->Enabled = false;
this->timer_game->Start();
int limit = 60000;
while (/*пока время в таймере не ноль, как?*/) {
srand(time(0));
int cube = 1 + rand()%16; // для активации рандомной кнопки
if ((this->button_out->Tag) == 1) { //пытался сделать проверку нажати кнопки
this->button_start->Enabled = true;
break;
}
}
this->button1->Enabled = true;// решил проверить правильность работы
}
private: System::Void button_out_Click(System::Object^ sender, System::EventArgs^ e) {
this->button_out->Tag = 1;
}
};
}
Код копипастнут может и криво, но вроде всё видно, первый вопрос:)