Code Monkey home page Code Monkey logo

pvzclass's Introduction

pvzclass 是一个用于控制植物大战僵尸游戏内部运行实体的一套框架

pvzclass-with-events 附加

EventHandler是一个类。这个类可以被构造:

EventHandler(PVZ* pvz);

这个类可以注册所有的监听器:

  • PlantPlantEvent-PVZ::Plant*
  • PlantRemoveEvent-PVZ::Plant*
  • PlantUpgradeEvent-PVZ::Plant*
  • LevelOpenEvent-void
  • LevelCloseEvent-void
  • LevelWaveEvent-int

格式: 注册名——函数传递参数

注册监听器需要将register放到前面。

  • RegisterPlantPlantEvent(...)

Run 代表运行一次监听器。

注意:Run只能进行一次监听,不能持久,不会多开线程

监听的函数必须有一个相对应的参数。

void onPlant( PVZ::Plant *e )

代码:

#include "events.h"
///...
void plant(PVZ::Plant e)//e与参数对应
{
	cout << "found Plant on " << e.Row << " " << e.Column << " " << ToString(e.Type) << endl;
}
void open(void)//其实这里void可以拿走
{
        cout << "open" << endl;
}
void wave(int w)
{
        cout << "wave is: " << wave << endl;
}
//...
int main()
{
//...
	EventHandler e(pvz);
	e.RegisterPlantPlantEvent(plant);
	e.RegisterLevelOpenEvent(open);
	while (1)
		e.Run();      //进行一次监听
//...
}

=======

pvzclass-with-events

pvzclass 是一个用于控制植物大战僵尸游戏内部运行实体的一套框架

with events?

在处理时有种种问题,例如:

  • 如何知道玩家种下了一棵植物?
  • 如何知道玩家铲掉或僵尸啃掉了一棵植物?

等这些问题,或许不需要事件监听,但会比较繁琐。

本人受到Bukkit Events API启发。

将会不断完善其它的事件。

(新人刚来)

安装方法

手动安装(推荐)

直接打包zip吧。

手动安装2

请先下载pvzclass,然后在PVZ.cpp中找到

	class Plant
	{
		int BaseAddress;
#if _DEBUG
		PlantType::PlantType DebugType;
#endif
	public:
		Plant(int indexoraddress);

将其修改为:

	class Plant
	{
	public:
		int BaseAddress;
#if _DEBUG
		PlantType::PlantType DebugType;
#endif
		Plant(int indexoraddress);

然后下载EventHandler.h/.cpp就完成了。

##怎么用?

pvzclass.cpp。

pvzclass's People

Contributors

lazuplis-mei avatar theflysong avatar violet-nonbloosom avatar youtheb avatar 63enjoy avatar fxmlesxd avatar fhohfguo avatar infdust avatar lengjunyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.