基于文本的RPG [英] Text based RPG

查看:73
本文介绍了基于文本的RPG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

制作我的技术中心女巫所需的RPG几乎是我学校的一半。现在,我对社区中的一些人提供了很多帮助的向量有很好的理解。对,我想知道如何将一个矢量位置转移到另一个矢量。如何从库存到交易商/地面交易/放弃物品。现在我有清单中的物品清单:

Making a RPG that will be required for my tech center witch is half of my school pretty much. Right now I have a good understanding of vectors with lots of help from some people in the community here. Right I want to know how to transfer over one vectors location to another vector. How do I trade/drop items from inventory to trader/ground. Right now i have the list of items that is in inventory:

展开 | 选择 | Wrap | 行号

推荐答案

您的InventoryItem结构具有一个字符串成员和两个int成员。当你复制一个InventoryItem时,编译器会单独复制每个成员。

对字符串进行处理并且int是C ++语言的一部分,他们知道如何复制这些成员以便你不要我们需要担心他们是如何做到的。


所以要在MyStuff中复制InvnetoryItem并将副本放在Market1中你编码:

Your InventoryItem struct has a string member and two int members. When you copy an InventoryItem, each member is separately copied by the compiler.

Sincs the string and the int are part of the C++ language, they know how to copy theselves so you don''t need to worry about how they do that.

So to make copy of an InvnetoryItem in MyStuff and put the copy in Market1 you code:

展开 | 选择 | Wrap | 行号


我有一个赚钱系统的时间我有这个想法,但我不知道我是否应该使用一个简单的int存钱的钱钱或者我必须使用矢量才能使它工作。


这是我的所有代码:
I am having a dificual time with a money system I have the idea but I don''t know if I should use a simple int money to store the money or if I have to use a vector to make it work.

This is all my code:
展开 | 选择 | Wrap | 行号


我不知道为什么你会使用一个名为Money的向量。


你向InventoryItem添加了价格,这样'只是另一个成员维护在使用InventoryItem的代码中。


因为您添加了此成员,所以您需要确保您创建的每个InventoryItem都具有所有三个成员的有效值。稍后当你使用这些InventryItem对象时,代码会期望每个对象都被正确初始化。


对于一个int来换钱,这是正确的方法。您可以决定以便士价格保持价格。然后你只需添加,减去等便士的价值。只有当你出示使用金额时才需要担心123必须显示为
I don''t know why you would use a vector called Money.

You added price to the InventoryItem so that''s just another member to maintain in the code that uses InventoryItem.

Because you added this member, you need to be sure that every InventoryItem you create has valid values for all three members. Later on when you use these InventryItem objects that code will expect that each object is correctly initialized.

As to an int for money, that is the correct approach. You can decide to keep the price in pennies. Then you just add, subtract, etc values of pennies. Only when you dispay the amount for the use do you need to worry that 123 must appear as


这篇关于基于文本的RPG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆